1
1
import { Worker } from "near-workspaces" ;
2
2
import test from "ava" ;
3
- import {
4
- formatGas ,
5
- gasBreakdown ,
6
- logGasBreakdown ,
7
- logGasDetail ,
8
- } from "./util.js" ;
3
+ import { generateGasObject , logTestResults } from "./util.js" ;
4
+ import { addTestResults } from "./results-store.js" ;
9
5
10
6
test . before ( async ( t ) => {
11
7
// Init the worker and start a Sandbox server
@@ -47,51 +43,21 @@ test("JS promise batch deploy contract and call", async (t) => {
47
43
let r = await bob . callRaw ( callerContract , "deploy_contract" , "" , {
48
44
gas : "300 Tgas" ,
49
45
} ) ;
50
- // console.log(JSON.stringify(r, null, 2));
46
+
51
47
let deployed = callerContract . getSubAccount ( "a" ) ;
48
+
52
49
t . deepEqual ( JSON . parse ( Buffer . from ( r . result . status . SuccessValue , "base64" ) ) , {
53
50
currentAccountId : deployed . accountId ,
54
51
signerAccountId : bob . accountId ,
55
52
predecessorAccountId : callerContract . accountId ,
56
53
input : "abc" ,
57
54
} ) ;
58
55
59
- t . log (
60
- "Gas used to convert transaction to receipt: " ,
61
- formatGas ( r . result . transaction_outcome . outcome . gas_burnt )
62
- ) ;
63
- t . log (
64
- "Gas used to execute the receipt (actual contract call): " ,
65
- formatGas ( r . result . receipts_outcome [ 0 ] . outcome . gas_burnt )
66
- ) ;
67
- let map = gasBreakdown ( r . result . receipts_outcome [ 0 ] . outcome ) ;
68
- logGasBreakdown ( map , t ) ;
69
- t . log (
70
- "Gas used to execute the cross contract call: " ,
71
- formatGas ( r . result . receipts_outcome [ 1 ] . outcome . gas_burnt )
72
- ) ;
73
- map = gasBreakdown ( r . result . receipts_outcome [ 1 ] . outcome ) ;
74
- logGasBreakdown ( map , t ) ;
75
- t . log (
76
- "Gas used to refund unused gas for cross contract call: " ,
77
- formatGas ( r . result . receipts_outcome [ 2 ] . outcome . gas_burnt )
78
- ) ;
79
- t . log (
80
- "Gas used to refund unused gas: " ,
81
- // TODO: fix after near-workspaces is updated
82
- formatGas ( r . result . receipts_outcome [ 3 ] ?. outcome . gas_burnt || 0 )
83
- ) ;
84
- t . log (
85
- "Total gas used: " ,
86
- formatGas (
87
- r . result . transaction_outcome . outcome . gas_burnt +
88
- r . result . receipts_outcome [ 0 ] . outcome . gas_burnt +
89
- r . result . receipts_outcome [ 1 ] . outcome . gas_burnt +
90
- r . result . receipts_outcome [ 2 ] . outcome . gas_burnt +
91
- // TODO: fix after near-workspaces is updated
92
- ( r . result . receipts_outcome [ 3 ] ?. outcome . gas_burnt || 0 )
93
- )
94
- ) ;
56
+ logTestResults ( r ) ;
57
+
58
+ const gasObject = generateGasObject ( r ) ;
59
+
60
+ addTestResults ( "JS_promise_batch_deploy_contract_and_call" , gasObject ) ;
95
61
} ) ;
96
62
97
63
test ( "RS promise batch deploy contract and call" , async ( t ) => {
@@ -100,49 +66,19 @@ test("RS promise batch deploy contract and call", async (t) => {
100
66
let r = await bob . callRaw ( callerContractRs , "deploy_contract" , "" , {
101
67
gas : "300 Tgas" ,
102
68
} ) ;
103
- // console.log(JSON.stringify(r, null, 2));
69
+
104
70
let deployed = callerContractRs . getSubAccount ( "a" ) ;
71
+
105
72
t . deepEqual ( JSON . parse ( Buffer . from ( r . result . status . SuccessValue , "base64" ) ) , {
106
73
currentAccountId : deployed . accountId ,
107
74
signerAccountId : bob . accountId ,
108
75
predecessorAccountId : callerContractRs . accountId ,
109
76
input : "abc" ,
110
77
} ) ;
111
78
112
- t . log (
113
- "Gas used to convert transaction to receipt: " ,
114
- formatGas ( r . result . transaction_outcome . outcome . gas_burnt )
115
- ) ;
116
- t . log (
117
- "Gas used to execute the receipt (actual contract call): " ,
118
- formatGas ( r . result . receipts_outcome [ 0 ] . outcome . gas_burnt )
119
- ) ;
120
- let map = gasBreakdown ( r . result . receipts_outcome [ 0 ] . outcome ) ;
121
- logGasBreakdown ( map , t ) ;
122
- t . log (
123
- "Gas used to execute the cross contract call: " ,
124
- formatGas ( r . result . receipts_outcome [ 1 ] . outcome . gas_burnt )
125
- ) ;
126
- map = gasBreakdown ( r . result . receipts_outcome [ 1 ] . outcome ) ;
127
- logGasBreakdown ( map , t ) ;
128
- t . log (
129
- "Gas used to refund unused gas for cross contract call: " ,
130
- formatGas ( r . result . receipts_outcome [ 2 ] . outcome . gas_burnt )
131
- ) ;
132
- t . log (
133
- "Gas used to refund unused gas: " ,
134
- // TODO: fix after near-workspaces is updated
135
- formatGas ( r . result . receipts_outcome [ 3 ] ?. outcome . gas_burnt || 0 )
136
- ) ;
137
- t . log (
138
- "Total gas used: " ,
139
- formatGas (
140
- r . result . transaction_outcome . outcome . gas_burnt +
141
- r . result . receipts_outcome [ 0 ] . outcome . gas_burnt +
142
- r . result . receipts_outcome [ 1 ] . outcome . gas_burnt +
143
- r . result . receipts_outcome [ 2 ] . outcome . gas_burnt +
144
- // TODO: fix after near-workspaces is updated
145
- ( r . result . receipts_outcome [ 3 ] ?. outcome . gas_burnt || 0 )
146
- )
147
- ) ;
79
+ logTestResults ( r ) ;
80
+
81
+ const gasObject = generateGasObject ( r ) ;
82
+
83
+ addTestResults ( "RS_promise_batch_deploy_contract_and_call" , gasObject ) ;
148
84
} ) ;
0 commit comments