1
+ const Orbs = require ( "../../dist/index.js" ) ;
2
+
3
+ const GAMMA_PORT = 8080 ;
4
+ const GAMMA_ENDPOINT = "localhost" ;
5
+ const VIRTUAL_CHAIN_ID = 42 ;
6
+
7
+ test ( "E2E nodejs: CreateAccount" , ( ) => {
8
+ const account = Orbs . createAccount ( ) ;
9
+ console . log ( account . address ) ;
10
+ expect ( account . publicKey . byteLength ) . toBe ( 32 ) ;
11
+ expect ( account . privateKey . byteLength ) . toBe ( 64 ) ;
12
+ } ) ;
13
+
14
+ test . skip ( "E2E nodejs: SimpleTransfer" , async ( ) => {
15
+ // TODO: start gamma here
16
+
17
+ // create sender account
18
+ const sender = Orbs . createAccount ( ) ;
19
+
20
+ // create receiver account
21
+ const receiver = Orbs . createAccount ( ) ;
22
+
23
+ // create client
24
+ const endpoint = `http://${ GAMMA_ENDPOINT } :${ GAMMA_PORT } ` ;
25
+ const client = new Orbs . Client ( endpoint , VIRTUAL_CHAIN_ID , "TEST_NET" ) ;
26
+
27
+ // create transfer transaction payload
28
+ const [ payload1 , txId ] = client . createSendTransactionPayload (
29
+ sender . publicKey ,
30
+ sender . privateKey ,
31
+ "BenchmarkToken" ,
32
+ "transfer" ,
33
+ [ new Orbs . Uint64Arg ( 10 ) , new Orbs . BytesArg ( receiver . rawAddress ) ]
34
+ ) ;
35
+
36
+ // send the payload
37
+ const transferResponse = await client . sendTransaction ( payload1 ) ;
38
+ expect ( transferResponse . requestStatus ) . toEqual ( "COMPLETED" ) ;
39
+ expect ( transferResponse . executionResult ) . toEqual ( "SUCCESS" ) ;
40
+ expect ( transferResponse . transactionStatus ) . toEqual ( "COMMITTED" ) ;
41
+
42
+ // create get status payload
43
+ const payload2 = client . createGetTransactionStatusPayload ( txId ) ;
44
+
45
+ // send the payload
46
+ const statusResponse = await client . getTransactionStatus ( payload2 ) ;
47
+ expect ( statusResponse . requestStatus ) . toEqual ( "COMPLETED" ) ;
48
+ expect ( statusResponse . executionResult ) . toEqual ( "SUCCESS" ) ;
49
+ expect ( statusResponse . transactionStatus ) . toEqual ( "COMMITTED" ) ;
50
+
51
+ // create balance method call payload
52
+ const payload3 = client . createCallMethodPayload (
53
+ receiver . publicKey ,
54
+ "BenchmarkToken" ,
55
+ "getBalance" ,
56
+ [ new Orbs . BytesArg ( receiver . rawAddress ) ]
57
+ ) ;
58
+
59
+ // send the payload
60
+ const balanceResponse = await client . callMethod ( payload3 ) ;
61
+ expect ( balanceResponse . requestStatus ) . toEqual ( "COMPLETED" ) ;
62
+ expect ( balanceResponse . executionResult ) . toEqual ( "SUCCESS" ) ;
63
+ expect ( balanceResponse . OutputArguments [ 0 ] ) . toEqual ( new Orbs . Uint64Arg ( 10 ) ) ;
64
+
65
+ } ) ;
0 commit comments