Skip to content

Commit

Permalink
feat/#15 add unit test (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvo11 authored Apr 21, 2020
1 parent 61ff630 commit 638be4d
Show file tree
Hide file tree
Showing 17 changed files with 6,007 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.vscode
*.abi
*.wasm
node_modules
.idea
auth.json
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- '10'
before_install:
- mkdir ~/.hydra
- openssl aes-256-cbc -K $encrypted_2234089e6802_key -iv $encrypted_2234089e6802_iv -in auth.json.enc -out ~/.hydra/auth.json -d
58 changes: 45 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,58 @@ Dependencies:
* [can v1.0.x](https://github.com/canfoundation/CAN/releases/tag/can-v1.0.0)
* [eosio.cdt v1.7.x](https://github.com/EOSIO/eosio.cdt/releases/tag/v1.7.0)

Build the contracts:
## Build the contracts:
```
cd cryptobadge
eosio-cpp -abigen -I include -contract cryptobadge -o cryptobadge.wasm src/cryptobadge.cpp
```

## How to run unit test

Actions:
1. Install eosio testing framework [hydra](https://docs.klevoya.com/hydra/about/getting-started) and login into it:

## badge::regissuer issuer data
```bash
npm i -g @klevoya/hydra

hydra login
```

2. Install yarn packages:

```bash
yarn install
```

3. Run test:

Run all unit test

```bash
yarn test
```

Run test file:

```bash
yarn test cryptobadge.test.ts
```

***WARING*** Because test need to send many request to hydra server, test timeout error may sometime happend. Make sure your network connection is stable to run this test.


## Actions:

#### badge::regissuer issuer data
- Indicates that a particular account wishes to become a issuer
- **issuer** account registering to be a badge issuer who has permission to create badge
- **data** sha256 of issuer info

## badge::updateissuer issuer data
#### badge::updateissuer issuer data
- **issuer** account owner of issuer
- **data** sha256 updated issuer info

## badge::createbadge issuer version name image_url path description criteria
#### badge::createbadge issuer version name image_url path description criteria
- Create a new badge
- **issuer** the account registering as a issuer
- **badge_id** the id of badge, should be unique in scope of issuer
Expand All @@ -45,7 +77,7 @@ Actions:
- **description** the description of badge
- **criteria** the criteria of badge

## badge::updatebadge issuer badge_id version name image_url path description criteria
#### badge::updatebadge issuer badge_id version name image_url path description criteria
- **issuer** account has created badge
- **badge_id** id of badge
- **name** the name of badge
Expand All @@ -54,7 +86,7 @@ Actions:
- **description** the description of badge
- **criteria** the criteria of badge

## badge::issuebadge issuer owner idata require_claim
#### badge::issuebadge issuer owner idata require_claim
- Create a new certification
- **issuer** account whose onwer of badge_id
- **owner** account whose certification owner
Expand All @@ -64,37 +96,37 @@ Actions:
- **encrypted_data** ceritification encrypted data
- **require_claim** true or false. If disabled, upon creation, the certification will be transfered to owner but issuer'S memory will be used until the certification is transferred again). If enabled issuer will remain the owner, but an offer will be created for the account specified in the owner field to claim the certification using the account's RAM.

## badge::claimcert claimer cert_ids
#### badge::claimcert claimer cert_ids
- **claimer** account whose onwer of certification
- **cert_ids** list certifications to claim. The action will be failed if one cert_ids does not work
- Note : claimer must pay RAM for certification if they do this action

## badge::canceloffer issuer cert_ids
#### badge::canceloffer issuer cert_ids
- **issuer** current certification issuer account
- **cert_ids** list certifications to cancel offer
- Issuer only cancel offer when the certification still not issue it to owner

## badge::removecert owner cert_ids memo
#### badge::removecert owner cert_ids memo
- Deposits tokens to user REX fund
- **owner** current certification owner account
- **cert_ids** array of cert_id's to revoke
- **memo** memo for revoke action
- This action is only available for the certification owner. After executing, the certification will disappear forever, and RAM used for certification will be released.

## badge::attach owner cert_id data
#### badge::attach owner cert_id data
- public certification detail. Action is not mandatory
- **owner** certification owner account
- **cert_id** id of certificastion when to public on blockchain
- **data** json stringify data of certification
- Note: once the certification is public, there are no way to remove data on blockchain

## badge::detach owner cert_ids
#### badge::detach owner cert_ids
- Detach certification detail. Action is not mandatory.
- **owner** certification owner account
- **cert_ids** list of id certification
- The Ram will be release

## badge::createlog issuer owner idata cert_id require_claim
#### badge::createlog issuer owner idata cert_id require_claim
- Empty action. Used by create action to log cert_id so that third party explorers can easily get new certification ids and other information.


Expand Down
Binary file added auth.json.enc
Binary file not shown.
Loading

0 comments on commit 638be4d

Please sign in to comment.