twinstake / permissioned-delegation-matic

0 stars 0 forks source link

Tests fail: `Error: Expected private key to be an Uint8Array with length 32` #1

Open eliotstock opened 1 year ago

eliotstock commented 1 year ago

I ran tests with:

npm install
npx hardhat help
npx hardhat test test/units/staking/ValidatorShare.test.ts

They failed with:

...
Compiled 131 Solidity files successfully

  ValidatorShare
    1) "before all" hook in "ValidatorShare"

  0 passing (1s)
  1 failing

  1) ValidatorShare
       "before all" hook in "ValidatorShare":
     Error: Expected private key to be an Uint8Array with length 32
      at assert (node_modules/secp256k1/lib/index.js:18:20)
      at isUint8Array (node_modules/secp256k1/lib/index.js:31:7)
      at privateKeyVerify (node_modules/secp256k1/lib/index.js:66:7)
      at isValidPrivate (node_modules/ethereumjs-util/src/account.ts:231:26)
      at new Wallet (node_modules/ethereumjs-wallet/src/index.ts:249:38)
      at Function.fromPrivateKey (node_modules/ethereumjs-wallet/src/index.ts:326:12)
      at getWallets (test/units/staking/deployment.ts:47:25)
      at async Context.<anonymous> (test/units/staking/ValidatorShare.test.ts:143:20)
rac-sri commented 1 year ago

Looks like something in your private key formatting, "0x" should be prefixed. I have pushed a env example file. Screenshot 2023-05-10 at 10 33 36 AM

eliotstock commented 1 year ago

Your README.md says nothing about creating an .env file, so I don't have one. Even your new example file doesn't explain what to put in it. Am I supposed to generate a new key and mnemonic? How?

If any key will do, why doesn't the test code create one itself?

And if the tests depend on this file existing and it doesn't, the failure message should say that the file doesn't exist, not that the type of something or other isn't what was expected.

rac-sri commented 1 year ago

added details about .env to README.md