diff --git a/test_environment.js b/test_environment.js index 714c122c..d3161a89 100644 --- a/test_environment.js +++ b/test_environment.js @@ -2,6 +2,8 @@ const NodeEnvironment = require('jest-environment-node'); const nearlib = require('nearlib'); const fs = require('fs'); +const testAccountName = 'test.near'; + class LocalTestEnvironment extends NodeEnvironment { constructor(config) { super(config); @@ -16,13 +18,15 @@ class LocalTestEnvironment extends NodeEnvironment { contractName: "test" + Date.now(), accountId: "test" + Date.now() }); + const keyStore = new nearlib.keyStores.InMemoryKeyStore(); + await keyStore.setKey(config.networkId, testAccountName, nearlib.utils.KeyPair.fromString('ed25519:2wyRcSwSuHtRVmkMCGjPwnzZmQLeXLzLLyED1NDMt4BjnKgQL6tF85yBx6Jr26D2dUNeC716RBoTxntVHsegogYw')); config.deps = Object.assign(config.deps || {}, { storage: this.createFakeStorage(), - keyStore: new nearlib.keyStores.InMemoryKeyStore(), + keyStore, }); const near = await nearlib.connect(config); - const masterAccount = near.account('test.near'); + const masterAccount = await near.account(testAccountName); const randomKey = await nearlib.KeyPair.fromRandom('ed25519'); const data = [...fs.readFileSync('./out/main.wasm')]; await masterAccount.createAndDeployContract(config.contractName, randomKey.getPublicKey(), data, 1000000);