@@ -12,14 +12,8 @@ import { randomBytes } from 'crypto'
1212import { API , KeyPair , Account } from '../../src'
1313import { isAddress , toAddress } from '../../src/Utils'
1414
15- const PRIVATE_TEST_KEY_TEXT = `
16- -----BEGIN ENCRYPTED PRIVATE KEY-----
17- MIGbMFcGCSqGSIb3DQEFDTBKMCkGCSqGSIb3DQEFDDAcBAi3qm1zgjCO5gICCAAw
18- DAYIKoZIhvcNAgkFADAdBglghkgBZQMEASoEENjvj1nzc0Qy22L+Zi+n7yIEQMLW
19- o++Jzwlcg3PbW1Y2PxicdFHM3dBOgTWmGsvfZiLhSxTluXTNRCZ8ZLL5pi7JWtCl
20- JAr4iFzPLkM18YEP2ZE=
21- -----END ENCRYPTED PRIVATE KEY-----
22- `
15+
16+ const PRIVATE_ENCRYPTED_KEY = 'U2FsdGVkX1+zZPlLL1zR8ac9kCp+lHWGsjpUwBINwhpnTJWlu4TctG/Zha/8Mx0ZXjMbb73KZN+N/pBawfTmmw=='
2317
2418const PRIVATE_TEST_KEY_PASSWORD = 'secret'
2519
@@ -29,6 +23,7 @@ const TOPUP_AMOUNT = 10000000
2923describe ( 'API Class' , ( ) => {
3024 describe ( 'requestFunds' , async ( ) => {
3125 it ( 'should request funds from a new account' , async ( ) => {
26+
3227 const convex = API . create ( CONVEX_URL )
3328 const keyPair = await KeyPair . create ( )
3429 const account = await convex . createAccount ( keyPair )
@@ -39,7 +34,7 @@ describe('API Class', () => {
3934
4035 it ( 'should request funds from the test account' , async ( ) => {
4136 const convex = API . create ( CONVEX_URL )
42- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
37+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
4338 const account = await convex . createAccount ( importKeyPair )
4439 const amount = 1000000
4540 const result = await convex . requestFunds ( amount , account )
@@ -58,7 +53,7 @@ describe('API Class', () => {
5853
5954 it ( 'should return a valid checksum address from a query' , async ( ) => {
6055 const convex = API . create ( CONVEX_URL )
61- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
56+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
6257 const account = await convex . createAccount ( importKeyPair )
6358 const address = account . address
6459 const result = await convex . query ( `(address #${ address } )` , account )
@@ -103,7 +98,7 @@ describe('API Class', () => {
10398 let account
10499 before ( async ( ) => {
105100 convex = API . create ( CONVEX_URL )
106- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
101+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
107102 account = await convex . createAccount ( importKeyPair )
108103 await convex . topupAccount ( account )
109104 } )
@@ -151,7 +146,7 @@ describe('API Class', () => {
151146 let functionAddress
152147 before ( async ( ) => {
153148 convex = API . create ( CONVEX_URL )
154- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
149+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
155150 account = await convex . createAccount ( importKeyPair )
156151 await convex . topupAccount ( account )
157152 functionName = 'test-storage'
@@ -204,7 +199,7 @@ describe('API Class', () => {
204199 let accountName
205200 before ( async ( ) => {
206201 convex = API . create ( CONVEX_URL )
207- importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
202+ importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
208203 accountName = 'test.convex-api.' + randomBytes ( 4 ) . toString ( 'hex' )
209204 } )
210205 it ( 'should fail to reslove a new named account' , async ( ) => {
@@ -224,7 +219,7 @@ describe('API Class', () => {
224219 let newAccount : Account
225220 before ( async ( ) => {
226221 convex = API . create ( CONVEX_URL )
227- importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
222+ importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
228223 accountName = 'test.convex-api.' + randomBytes ( 4 ) . toString ( 'hex' )
229224 } )
230225 it ( 'should setup and setup/create a new named account' , async ( ) => {
@@ -278,7 +273,7 @@ describe('API Class', () => {
278273 let account
279274 before ( async ( ) => {
280275 convex = API . create ( CONVEX_URL )
281- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
276+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
282277 account = await convex . createAccount ( importKeyPair )
283278 await convex . requestFunds ( TOPUP_AMOUNT , account )
284279 } )
@@ -300,7 +295,7 @@ describe('API Class', () => {
300295 let accountFrom
301296 before ( async ( ) => {
302297 convex = API . create ( CONVEX_URL )
303- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
298+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
304299 accountFrom = await convex . createAccount ( importKeyPair )
305300 await convex . topupAccount ( accountFrom )
306301 } )
@@ -322,7 +317,7 @@ describe('API Class', () => {
322317 let account
323318 before ( async ( ) => {
324319 convex = API . create ( CONVEX_URL )
325- const importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
320+ const importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
326321 account = await convex . createAccount ( importKeyPair )
327322 await convex . topupAccount ( account )
328323 } )
@@ -348,7 +343,7 @@ describe('API Class', () => {
348343 let importKeyPair
349344 before ( async ( ) => {
350345 convex = API . create ( CONVEX_URL )
351- importKeyPair = await KeyPair . importFromString ( PRIVATE_TEST_KEY_TEXT , PRIVATE_TEST_KEY_PASSWORD )
346+ importKeyPair = await KeyPair . importFromString ( PRIVATE_ENCRYPTED_KEY , PRIVATE_TEST_KEY_PASSWORD )
352347 } )
353348 it ( 'should run multiple createAccount test' , async ( ) => {
354349 const requestCount = 20
0 commit comments