From 17fdd30858e819e6fc21b9d58de291c69d85c92d Mon Sep 17 00:00:00 2001 From: Illia Polosukhin Date: Wed, 19 Jun 2019 20:57:21 +0800 Subject: [PATCH] Add default test key into keystore --- test_environment.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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);