1
1
import * as helper from '../../app/helper.js' ;
2
2
import { installAndApprove , commit , getContract } from '../testutil.js' ;
3
+ import assert from 'assert' ;
3
4
4
5
const chaincodeID = 'ecosystem' ;
5
6
const orderers = helper . newOrderers ( ) ;
@@ -24,13 +25,27 @@ describe('deploy', function () {
24
25
describe ( 'invoke' , function ( ) {
25
26
this . timeout ( 0 ) ;
26
27
const contract = getContract ( chaincodeID ) ;
28
+ const transientMap = {
29
+ token : 'secret'
30
+ } ;
27
31
it ( 'CreateToken' , async ( ) => {
28
- try {
29
- await contract . submitTransaction ( 'CreateToken' , JSON . stringify ( { Owner : 'icddMSP' , MintTime : new Date ( ) } ) ) ;
30
- } catch ( e ) {
31
- console . error ( e ) ;
32
- }
33
-
32
+ await contract . submit ( [ 'CreateToken' , JSON . stringify ( { Owner : 'David' } ) ] , transientMap ) ;
33
+ await assert . rejects ( contract . submit ( [ 'CreateToken' , JSON . stringify ( { Owner : 'David' } ) ] , transientMap ) ) ;
34
+ } ) ;
35
+ it ( 'GetToken' , async ( ) => {
36
+ const tokenData = await contract . evaluate ( [ 'GetToken' ] , transientMap ) ;
37
+ console . info ( tokenData ) ;
38
+ } ) ;
39
+ it ( 'MoveToken' , async ( ) => {
40
+ await contract . submit ( [ 'MoveToken' , JSON . stringify ( { Owner : 'Chloe' , OwnerType : 'network' } ) ] , transientMap ) ;
41
+ } ) ;
42
+ it ( 'TokenHistory' , async ( ) => {
43
+ const history = await contract . evaluate ( [ 'TokenHistory' ] , transientMap ) ;
44
+ console . info ( JSON . parse ( history ) ) ;
34
45
35
46
} ) ;
47
+ it ( 'DeleteToken' , async ( ) => {
48
+ await contract . submit ( [ 'DeleteToken' ] , transientMap ) ;
49
+ } ) ;
50
+
36
51
} ) ;
0 commit comments