15
15
*
16
16
* @mocha -environment steps
17
17
*/
18
-
19
18
import { AccountId , PrivateKey } from '@hashgraph/sdk'
20
19
import { constants } from '../../../src/core/index.mjs'
21
20
import * as version from '../../../version.mjs'
@@ -29,11 +28,13 @@ import {
29
28
import { AccountCommand } from '../../../src/commands/account.mjs'
30
29
import { flags } from '../../../src/commands/index.mjs'
31
30
import { getNodeLogs } from '../../../src/core/helpers.mjs'
31
+ import { MINUTES , SECONDS } from '../../../src/core/constants.mjs' ;
32
+
33
+ const defaultTimeout = 20 * SECONDS
32
34
33
35
describe ( 'AccountCommand' , ( ) => {
34
36
const testName = 'account-cmd-e2e'
35
37
const namespace = testName
36
- const defaultTimeout = 20000
37
38
const testSystemAccounts = [ [ 3 , 5 ] ]
38
39
const argv = getDefaultArgv ( )
39
40
argv [ flags . namespace . name ] = namespace
@@ -44,7 +45,7 @@ describe('AccountCommand', () => {
44
45
argv [ flags . clusterName . name ] = TEST_CLUSTER
45
46
argv [ flags . fstChartVersion . name ] = version . FST_CHART_VERSION
46
47
// set the env variable SOLO_FST_CHARTS_DIR if developer wants to use local FST charts
47
- argv [ flags . chartDirectory . name ] = process . env . SOLO_FST_CHARTS_DIR ? process . env . SOLO_FST_CHARTS_DIR : undefined
48
+ argv [ flags . chartDirectory . name ] = process . env . SOLO_FST_CHARTS_DIR ?? undefined
48
49
const bootstrapResp = bootstrapNetwork ( testName , argv )
49
50
const accountCmd = new AccountCommand ( bootstrapResp . opts , testSystemAccounts )
50
51
bootstrapResp . cmd . accountCmd = accountCmd
@@ -54,7 +55,7 @@ describe('AccountCommand', () => {
54
55
const nodeCmd = bootstrapResp . cmd . nodeCmd
55
56
56
57
after ( async function ( ) {
57
- this . timeout ( 180_000 )
58
+ this . timeout ( 3 * MINUTES )
58
59
59
60
await getNodeLogs ( k8 , namespace )
60
61
await k8 . deleteNamespace ( namespace )
@@ -67,43 +68,45 @@ describe('AccountCommand', () => {
67
68
it ( `proxy should be UP: ${ nodeId } ` , async ( ) => {
68
69
await k8 . waitForPodReady (
69
70
[ `app=haproxy-${ nodeId } ` , 'fullstack.hedera.com/type=haproxy' ] ,
70
- 1 , 300 , 2000 )
71
- } ) . timeout ( 30_000 )
71
+ 1 , 300 , 2 * SECONDS )
72
+ } ) . timeout ( 30 * SECONDS )
72
73
}
73
74
} )
74
75
75
76
describe ( 'account init command' , ( ) => {
76
77
it ( 'should succeed with init command' , async ( ) => {
77
78
const status = await accountCmd . init ( argv )
78
79
expect ( status ) . to . be . ok
79
- } ) . timeout ( 180_000 )
80
+ } ) . timeout ( 3 * MINUTES )
80
81
81
82
describe ( 'special accounts should have new keys' , ( ) => {
82
83
const genesisKey = PrivateKey . fromStringED25519 ( constants . GENESIS_KEY )
83
84
const realm = constants . HEDERA_NODE_ACCOUNT_ID_START . realm
84
85
const shard = constants . HEDERA_NODE_ACCOUNT_ID_START . shard
85
86
86
87
before ( async function ( ) {
87
- this . timeout ( 20_000 )
88
+ this . timeout ( 20 * SECONDS )
88
89
await accountManager . loadNodeClient ( namespace )
89
90
} )
90
91
91
92
after ( async function ( ) {
92
- this . timeout ( 20_000 )
93
+ this . timeout ( 20 * SECONDS )
93
94
await accountManager . close ( )
94
95
} )
95
96
96
97
for ( const [ start , end ] of testSystemAccounts ) {
97
98
for ( let i = start ; i <= end ; i ++ ) {
98
99
it ( `account ${ i } should not have genesis key` , async ( ) => {
99
100
expect ( accountManager . _nodeClient ) . not . to . be . null
101
+
100
102
const accountId = `${ realm } .${ shard } .${ i } `
101
103
nodeCmd . logger . info ( `Fetching account keys: accountId ${ accountId } ` )
102
104
const keys = await accountManager . getAccountKeys ( accountId )
103
105
nodeCmd . logger . info ( `Fetched account keys: accountId ${ accountId } ` )
106
+
104
107
expect ( keys . length ) . not . to . equal ( 0 )
105
108
expect ( keys [ 0 ] . toString ( ) ) . not . to . equal ( genesisKey . toString ( ) )
106
- } ) . timeout ( 20_000 )
109
+ } ) . timeout ( 20 * SECONDS )
107
110
}
108
111
}
109
112
} )
@@ -117,17 +120,20 @@ describe('AccountCommand', () => {
117
120
argv [ flags . amount . name ] = 200
118
121
await expect ( accountCmd . create ( argv ) ) . to . eventually . be . ok
119
122
const accountInfo = accountCmd . accountInfo
123
+
120
124
expect ( accountInfo ) . not . to . be . null
121
125
expect ( accountInfo . accountId ) . not . to . be . null
126
+
122
127
accountId1 = accountInfo . accountId
128
+
123
129
expect ( accountInfo . privateKey ) . not . to . be . null
124
130
expect ( accountInfo . publicKey ) . not . to . be . null
125
131
expect ( accountInfo . balance ) . to . equal ( configManager . getFlag ( flags . amount ) )
126
132
} catch ( e ) {
127
133
testLogger . showUserError ( e )
128
134
expect ( e ) . to . be . null
129
135
}
130
- } ) . timeout ( 40_000 )
136
+ } ) . timeout ( 40 * SECONDS )
131
137
132
138
it ( 'should create account with private key and hbar amount options' , async ( ) => {
133
139
try {
@@ -139,7 +145,7 @@ describe('AccountCommand', () => {
139
145
140
146
const accountInfo = accountCmd . accountInfo
141
147
expect ( accountInfo ) . not . to . be . null
142
- expect ( accountInfo . accountId ) . not . to . be . null )
148
+ expect ( accountInfo . accountId ) . not . to . be . null
143
149
accountId2 = accountInfo . accountId
144
150
expect ( accountInfo . privateKey . toString ( ) ) . to . equal ( constants . GENESIS_KEY )
145
151
expect ( accountInfo . publicKey ) . not . to . be . null
@@ -184,7 +190,7 @@ describe('AccountCommand', () => {
184
190
expect ( accountInfo . accountId ) . to . equal ( argv [ flags . accountId . name ] )
185
191
expect ( accountInfo . privateKey ) . to . be . undefined
186
192
expect ( accountInfo . publicKey ) . not . to . be . null
187
- expect ( accountInfo . balance ) . to . equal ( 1110 )
193
+ expect ( accountInfo . balance ) . to . equal ( 1_110 )
188
194
} catch ( e ) {
189
195
testLogger . showUserError ( e )
190
196
expect ( e ) . to . be . null
@@ -220,7 +226,7 @@ describe('AccountCommand', () => {
220
226
expect ( accountInfo . accountId ) . to . equal ( argv [ flags . accountId . name ] )
221
227
expect ( accountInfo . privateKey ) . to . be . undefined
222
228
expect ( accountInfo . publicKey ) . to . be . ok
223
- expect ( accountInfo . balance ) . to . equal ( 1110 )
229
+ expect ( accountInfo . balance ) . to . equal ( 1_110 )
224
230
} catch ( e ) {
225
231
testLogger . showUserError ( e )
226
232
expect ( e ) . to . be . null
0 commit comments