near / near-workspaces-js

Write tests once, run them both on NEAR TestNet and a controlled NEAR Sandbox local environment
https://near.github.io/near-workspaces-js/
GNU General Public License v3.0
42 stars 21 forks source link

KeyNotFound for test.near account #167

Open valar999 opened 2 years ago

valar999 commented 2 years ago

Sometimes, in less than 5% of cases, this error appears.

Error (TypedError)

{ context: undefined, type: 'KeyNotFound', message: 'Can not sign transactions for account test.near on network sandbox, no matching key pair found in InMemorySigner(UnencryptedFileSystemKeyStore(/tmp/sandbox/8b20131f-f761-4c87-8976-470515b856f4)).', }

workspaces-js v2.0.0

My simplified code:

test.beforeEach(async (t) => {
 const worker = await Worker.init();
 const user = await worker.rootAccount.createAccount("user");
 });
volovyks commented 1 year ago

Most likely this is because the account was not actually created on-chain. We need to throw errors early here: https://github.com/near/workspaces-js/blob/main/packages/js/src/account/account.ts#L208