hoodquidity/packages/contracts/lib/openzeppelin-contracts/test/utils/NoncesKeyed.t.sol
Денис Зефиров dba2811447 Hoodquidity: liquidity campaigns for Robinhood Chain stock token markets
Full build: Vite/React acid-terminal frontend (BEARER design system,
Panchang/Sentient/Fragment Mono, neon layer, palette audit script),
HoodquidityVaults Foundry contracts (single+dual deposits via Chainlink-style
feeds, hybrid exit, 10% platform fee, boost, Genesis LP), Reown AppKit wallet
connect with Robinhood Chain testnet (46630), live data from Dexscreener and
onchain reads, partner portal, design-sync setup for claude.ai/design.

Deploy: static via Forgejo Actions platform, BUILD_DIR=apps/web/dist (.env).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 08:32:28 +04:00

51 lines
1.7 KiB
Solidity

// SPDX-License-Identifier: MIT
// This file was procedurally generated from scripts/generate/templates/Packing.t.js.
pragma solidity ^0.8.20;
import {Test} from "forge-std/Test.sol";
import {NoncesKeyed} from "@openzeppelin/contracts/utils/NoncesKeyed.sol";
import {Nonces} from "@openzeppelin/contracts/utils/Nonces.sol";
// CAUTION: Unsafe mock for testing purposes.
contract NoncesKeyedMock is NoncesKeyed {
function useNonce(address owner, uint192 key) public returns (uint256) {
return _useNonce(owner, key);
}
function useCheckedNonce(address owner, uint192 key, uint64 nonce) public {
_useCheckedNonce(owner, key, nonce);
}
}
contract NoncesKeyedTest is Test {
NoncesKeyedMock private _mock;
function setUp() public {
_mock = new NoncesKeyedMock();
}
function testSymbolicUseNonce(address owner, uint192 key) public {
uint256 prevNonce = _mock.useNonce(owner, key);
assertEq(prevNonce + 1, _mock.nonces(owner, key));
}
function testSymbolicUseCheckedNonceLiveness(address owner, uint192 key) public {
uint256 currNonce = _mock.nonces(owner, key);
// Does not revert
_mock.useCheckedNonce(owner, key, uint64(currNonce));
assertEq(currNonce + 1, _mock.nonces(owner, key));
}
function testUseCheckedNonce(address owner, uint192 key, uint64 nonce) public {
uint256 currNonce = _mock.nonces(owner, key);
if (uint64(currNonce) == nonce) {
_mock.useCheckedNonce(owner, key, nonce);
} else {
vm.expectRevert(abi.encodeWithSelector(Nonces.InvalidAccountNonce.selector, owner, currNonce));
_mock.useCheckedNonce(owner, key, nonce);
}
}
}