Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Add default test key into keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
ilblackdragon committed Jun 19, 2019
1 parent f2d837d commit 17fdd30
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test_environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 17fdd30

Please sign in to comment.