diff --git a/test/account.access_key.test.js b/test/account.access_key.test.js index 1392caa959..9bca32e0b8 100644 --- a/test/account.access_key.test.js +++ b/test/account.access_key.test.js @@ -12,12 +12,12 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; beforeAll(async () => { nearjs = await testUtils.setUpTestConnection(); - testAccount = await testUtils.createAccount(await nearjs.account(testUtils.testAccountName), { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); + testAccount = await testUtils.createAccount(nearjs, { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); }); beforeEach(async () => { contractId = testUtils.generateUniqueString('test'); - workingAccount = await testUtils.createAccount(testAccount); + workingAccount = await testUtils.createAccount(nearjs); contract = await testUtils.deployContract(workingAccount, contractId); }); diff --git a/test/account.test.js b/test/account.test.js index 6d65355543..f83f1cd51d 100644 --- a/test/account.test.js +++ b/test/account.test.js @@ -15,7 +15,7 @@ jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000; beforeAll(async () => { nearjs = await testUtils.setUpTestConnection(); - workingAccount = await testUtils.createAccount(await nearjs.account(testUtils.testAccountName), { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); + workingAccount = await testUtils.createAccount(nearjs, { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); let nodeStatus = await nearjs.connection.provider.status(); startFromVersion = (version) => semver.gte(nodeStatus.version.version, version); }); @@ -35,8 +35,8 @@ test('create account and then view account returns the created account', async ( }); test('send money', async() => { - const sender = await testUtils.createAccount(workingAccount); - const receiver = await testUtils.createAccount(workingAccount); + const sender = await testUtils.createAccount(nearjs); + const receiver = await testUtils.createAccount(nearjs); await sender.sendMoney(receiver.accountId, new BN(10000)); await receiver.fetchState(); const state = await receiver.state(); @@ -44,8 +44,8 @@ test('send money', async() => { }); test('delete account', async() => { - const sender = await testUtils.createAccount(workingAccount); - const receiver = await testUtils.createAccount(workingAccount); + const sender = await testUtils.createAccount(nearjs); + const receiver = await testUtils.createAccount(nearjs); await sender.deleteAccount(receiver.accountId); const reloaded = new nearApi.Account(sender.connection, sender); await expect(reloaded.state()).rejects.toThrow(); diff --git a/test/promise.test.js b/test/promise.test.js index 8794ee816d..6aabb29fed 100644 --- a/test/promise.test.js +++ b/test/promise.test.js @@ -10,7 +10,7 @@ const CONTRACT_CALL_GAS = new BN(300000000000000); beforeAll(async () => { nearjs = await testUtils.setUpTestConnection(); - workingAccount = await testUtils.createAccount(await nearjs.account(testUtils.testAccountName), { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); + workingAccount = await testUtils.createAccount(nearjs, { amount: testUtils.INITIAL_BALANCE.mul(new BN(100)) }); }); describe('with promises', () => { diff --git a/test/test-utils.js b/test/test-utils.js index 5f3ecee409..01bac5d5c2 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -25,12 +25,11 @@ function generateUniqueString(prefix) { return prefix + Date.now() + Math.round(Math.random() * 1000); } -async function createAccount(masterAccount, options = { amount: INITIAL_BALANCE, trials: 5 }) { - await masterAccount.fetchState(); +async function createAccount(near, options = { amount: INITIAL_BALANCE }) { const newAccountName = generateUniqueString('test'); - const newPublicKey = await masterAccount.connection.signer.createKey(newAccountName, networkId); - await masterAccount.createAccount(newAccountName, newPublicKey, options.amount); - return new nearApi.Account(masterAccount.connection, newAccountName); + const newPublicKey = await near.connection.signer.createKey(newAccountName, networkId); + await near.createAccount(newAccountName, newPublicKey, options.amount); + return new nearApi.Account(near.connection, newAccountName); } async function deployContract(workingAccount, contractId, options = { amount: INITIAL_BALANCE.div(new BN(10)) }) {