Skip to content

Commit

Permalink
[DONE] ecosystem.js
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkhala committed Jan 29, 2024
1 parent 4217aee commit 906d605
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions cc/golang/ecosystem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as helper from '../../app/helper.js';
import {installAndApprove, commit, getContract} from '../testutil.js';
import assert from 'assert';

const chaincodeID = 'ecosystem';
const orderers = helper.newOrderers();
Expand All @@ -24,13 +25,27 @@ describe('deploy', function () {
describe('invoke', function () {
this.timeout(0);
const contract = getContract(chaincodeID);
const transientMap = {
token: 'secret'
};
it('CreateToken', async () => {
try {
await contract.submitTransaction('CreateToken', JSON.stringify({Owner: 'icddMSP', MintTime: new Date()}));
} catch (e) {
console.error(e);
}

await contract.submit(['CreateToken', JSON.stringify({Owner: 'David'})], transientMap);
await assert.rejects(contract.submit(['CreateToken', JSON.stringify({Owner: 'David'})], transientMap));
});
it('GetToken', async () => {
const tokenData = await contract.evaluate(['GetToken'], transientMap);
console.info(tokenData);
});
it('MoveToken', async () => {
await contract.submit(['MoveToken', JSON.stringify({Owner: 'Chloe', OwnerType: 'network'})], transientMap);
});
it('TokenHistory', async () => {
const history = await contract.evaluate(['TokenHistory'], transientMap);
console.info(JSON.parse(history));

});
it('DeleteToken', async () => {
await contract.submit(['DeleteToken'], transientMap);
});

});

0 comments on commit 906d605

Please sign in to comment.