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

Intermittent failure in contracts/test/auth.ts #361

Closed
CedarMist opened this issue Aug 26, 2024 · 0 comments · Fixed by #375
Closed

Intermittent failure in contracts/test/auth.ts #361

CedarMist opened this issue Aug 26, 2024 · 0 comments · Fixed by #375
Assignees
Labels
bug contracts Pull requests that update sapphire-contracts tests Relating to tests

Comments

@CedarMist
Copy link
Member

CedarMist commented Aug 26, 2024

  1) Auth
       Should call authenticated method:
     TypeError: Expected a valid transaction hash, but got 'Very secret message'
      at onSuccess (/home/runner/work/sapphire-paratime/sapphire-paratime/node_modules/.pnpm/@[email protected]_@[email protected][email protected]_djiantmfwzd4h5mvs2d3iacurm/node_modules/@nomicfoundation/hardhat-chai-matchers/src/internal/reverted/reverted.ts:32:17)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async Context.<anonymous> (test/auth.ts:166:5)

Unable to reproduce locally.

// Expired bearer.
const siweStr4 = await siweMsg('localhost', 0, new Date(Date.now() + 10)); // Expire after 0.01 seconds.
const bearer4 = await siweAuthTests.testLogin(
siweStr4,
await erc191sign(siweStr4, account),
);
// Wait for 2 blocks. The first block may still have a timestamp earlier than the expiration time.
await new Promise(async (r) => {
const desiredBlockNumber = (await ethers.provider.getBlockNumber()) + 2;
ethers.provider.on('block', (blockNumber) => {
if (blockNumber == desiredBlockNumber) {
r();
}
});
});
await expect(siweAuthTests.testVerySecretMessage(bearer4)).to.be.reverted;

Presumably waiting 2 blocks isn't enough, it should sleep until the timestamp has really passed, and the bearer token will have expired.

@matevz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug contracts Pull requests that update sapphire-contracts tests Relating to tests
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants
@CedarMist and others