fix: workaround assumePayable

This commit is contained in:
rymnc 2023-03-29 17:51:48 +05:30
parent 7c081c1ad8
commit cae34e64d8
No known key found for this signature in database
GPG Key ID: C740033EE3F41EBD
3 changed files with 10 additions and 1 deletions

View File

@ -45,7 +45,7 @@ jobs:
run: yarn lint run: yarn lint
- id: test - id: test
run: yarn test run: yarn test:verbose
- id: coverage - id: coverage
run: yarn coverage run: yarn coverage

View File

@ -5,6 +5,7 @@
"start": "hardhat node --export-all deployments/allDeployments.json", "start": "hardhat node --export-all deployments/allDeployments.json",
"compile": "hardhat compile", "compile": "hardhat compile",
"test": "yarn test:foundry && yarn test:hardhat", "test": "yarn test:foundry && yarn test:hardhat",
"test:verbose": "yarn test:foundry -vvv && yarn test:hardhat --verbose",
"test:hardhat": "hardhat test", "test:hardhat": "hardhat test",
"test:hardhat:localhost": "yarn test:hardhat --network localhost", "test:hardhat:localhost": "yarn test:hardhat --network localhost",
"test:hardhat:sepolia": "yarn test:hardhat --network sepolia", "test:hardhat:sepolia": "yarn test:hardhat --network sepolia",

View File

@ -16,6 +16,9 @@ contract ArrayUnique {
seen[arr[i]] = true; seen[arr[i]] = true;
} }
} }
// contract in construction goes around the assumePayable() check
receive() external payable {}
} }
function repeatElementIntoArray( function repeatElementIntoArray(
@ -160,7 +163,9 @@ contract RLNTest is Test {
address payable to address payable to
) public { ) public {
// avoid precompiles, etc // avoid precompiles, etc
// TODO: wrap both of these in a single function
assumePayable(to); assumePayable(to);
assumeNoPrecompiles(to);
vm.assume(to != address(0)); vm.assume(to != address(0));
uint256 idCommitment = poseidon.hash(idSecretHash); uint256 idCommitment = poseidon.hash(idSecretHash);
@ -206,6 +211,7 @@ contract RLNTest is Test {
) public { ) public {
// avoid precompiles, etc // avoid precompiles, etc
assumePayable(to); assumePayable(to);
assumeNoPrecompiles(to);
vm.assume(to != address(0)); vm.assume(to != address(0));
uint256 idCommitment = poseidon.hash(idSecretHash); uint256 idCommitment = poseidon.hash(idSecretHash);
@ -234,6 +240,7 @@ contract RLNTest is Test {
) public { ) public {
// avoid precompiles, etc // avoid precompiles, etc
assumePayable(to); assumePayable(to);
assumeNoPrecompiles(to);
vm.assume(isUniqueArray(idSecretHashes) && idSecretHashes.length > 0); vm.assume(isUniqueArray(idSecretHashes) && idSecretHashes.length > 0);
vm.assume(to != address(0)); vm.assume(to != address(0));
uint256 idCommitmentlen = idSecretHashes.length; uint256 idCommitmentlen = idSecretHashes.length;
@ -276,6 +283,7 @@ contract RLNTest is Test {
address payable to address payable to
) public { ) public {
assumePayable(to); assumePayable(to);
assumeNoPrecompiles(to);
vm.assume(isUniqueArray(idSecretHashes) && idSecretHashes.length > 0); vm.assume(isUniqueArray(idSecretHashes) && idSecretHashes.length > 0);
vm.assume(to != address(0)); vm.assume(to != address(0));