Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: KeyNotFound, but it's there #128

Open
tifrel opened this issue Mar 22, 2022 · 5 comments
Open

Bug: KeyNotFound, but it's there #128

tifrel opened this issue Mar 22, 2022 · 5 comments
Labels
bug Something isn't working T-dev-tools

Comments

@tifrel
Copy link

tifrel commented Mar 22, 2022

I can currently not sign a transaction due to a missing key:

 Rejected promise returned by test. Reason:

 Error (TypedError) 

 { context: undefined, type: 'KeyNotFound', message: 'Can not sign transactions for account alice.factory.test.near on network sandbox, no matching key pair found in InMemorySigner(UnencryptedFileSystemKeyStore(/private/var/folders/pl/t18g62c96jdd1fcl5zmdgg680000gn/T/sandbox/9106bd6a-9750-4117-abf6-f2d07ac6a4f6)).', } 

Taking a look into that directory, the key pair does actually exist, as I have copied it over from the factory account as part of the tests. The test output confirms that. You can [check it out](https://github.com/Mintbase/mintbase-core/blob/0b6c0e388b35da3f6517cd41d085b80f6db29694/testing/tests/nft.upgrade.ava.ts), but I can not open-source the whole repo. I have also replaced the the UnencryptedFileSystemKeyStore for the offending account, but that doesn't work (see l. 197 in linked code). My best idea right now is that the InMemorySigner keeps an outdated version of UnencryptedFileSystemKeyStore, but I cannot find where to replace that signer.

@ailisp
Copy link
Member

ailisp commented Apr 11, 2022

We were able to reliably reproduce the same error in testnet, but sandbox were passed. The tests are: https://github.com/near-examples/nft-tutorial/tree/feat-testing/onchain_tests. We're working on a fix, and will see if that solves your problem.

@ailisp
Copy link
Member

ailisp commented Apr 11, 2022

For now you do a very quick workaround to sequentially run tests, which fixes the tests for me. Edit this file, node_modules/near-workspaces-ava/dist/index.js, change this line:

            (0, ava_1.default)(description, async (t) => {

to:

            (0, ava_1.serial)(description, async (t) => {

The problem is UnencryptedFileSystemKeyStore doesn't handle concurrent access of key files well. We're still investigating a fix, maybe in near-api-js.

@volovyks volovyks added the bug Something isn't working label Apr 12, 2022
@idea404
Copy link

idea404 commented Apr 14, 2022

I would add to this issue:

  • Running tests on testnet multiple times yield different results:
    • First run runs into this error for a subset of the tests running on testnet: Can not sign transactions for account
    • Second run, given there are "not that many tests" (in the case of this repo 3 tests)(even when run serially) all tests pass
  • As mentioned, there is an arbitrary maximum number of tests that may be run on testnet before a subset of the tests start obtaining Rejected Promise errors on testnet

@ailisp
Copy link
Member

ailisp commented Apr 19, 2022

@tifrel In our fails, this failure is due to the account creation failed (alice.factory.test.near). The keypair is there but the account wasn't successfully created will also give this error message (our bad :(), and it's much more frequent than the key really doesn't exist.

Please try:

const balance = await alice.availableBalance();
console.log(balance);

If it errors, we can confirm alice doesn't exist. Call availableBalance doesn't need key.

@tifrel
Copy link
Author

tifrel commented Apr 19, 2022

@ailisp Thanks a lot for your support. In my case, I have fixed the issue by not using the factory to deploy the contract, and instead testing the upgrade on a directly deployed store. I did however take the time to check this. alice exists on my sandbox node. Furthermore I tried the same with store, as that is the variable for account alice.factory.test.near. I checked everything in a repo where I didn't download the closed-source parts, to eliminate the chances of those interfering.

I'd like to add to this that all my other tests pass, and all of them require account creation. The only part where I am facing troubles is the key copying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working T-dev-tools
Projects
Status: NEW❗
Development

No branches or pull requests

4 participants