Skip to content

Commit

Permalink
found bug: external attester
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroknots committed Feb 21, 2024
1 parent 406e8f4 commit 629c25f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
2 changes: 0 additions & 2 deletions test/SchemaValidation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ contract SchemaValidationTest is BaseTest {
uid1 = registry.registerSchema(schema, IExternalSchemaValidator(address(schemaValidatorFalse)));

assertTrue(uid != uid1);

}

function test_WhenSchemaNew() external whenRegisteringNewSchema {
Expand All @@ -27,7 +26,6 @@ contract SchemaValidationTest is BaseTest {

assertTrue(uid != SchemaUID.wrap(bytes32(0)));


SchemaRecord memory record = registry.findSchema(uid);
assertEq(record.registeredAt, block.timestamp);
assertEq(keccak256(abi.encodePacked(record.schema)), keccak256(abi.encodePacked(schema)));
Expand Down
12 changes: 10 additions & 2 deletions test/TrustDelegation.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,23 @@ contract TrustTest is AttestationTest {
assertEq(result[0], address(attester1.addr));
}

function test_WhenSupplyingManyAttesters(address[] memory attesters) external whenSettingAttester prankWithAccount(smartAccount1) {
function test_WhenSupplyingManyAttesters(
uint8 threshold,
address[] memory attesters
)
external
whenSettingAttester
prankWithAccount(smartAccount1)
{
vm.assume(attesters.length < 100);
vm.assume(attesters.length > 0);
vm.assume(threshold <= attesters.length + 4);
for (uint256 i; i < attesters.length; i++) {
vm.assume(attesters[i] != address(0));
}
attesters.sort();
attesters.uniquifySorted();
registry.trustAttesters(uint8(attesters.length), attesters);
registry.trustAttesters(threshold, attesters);
// It should set.
// It should emit event.
address[] memory result = registry.findTrustedAttesters(smartAccount1.addr);
Expand Down
34 changes: 34 additions & 0 deletions test/TrustDelegationExternal.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import "./Attestation.t.sol";
import "src/DataTypes.sol";
import { LibSort } from "solady/utils/LibSort.sol";

contract TrustTestExternal is AttestationTest {
using LibSort for address[];

function setUp() public override {
super.setUp();
// test_WhenAttestingWithNoAttestationData(address(module1));
}

modifier whenSettingAttester() {
_;
}

function test_WhenSupplyingExternal() external whenSettingAttester {
// It should set.
test_WhenUsingValidECDSA();
address[] memory trustedAttesters = new address[](2);
trustedAttesters[0] = address(attester1.addr);
trustedAttesters[1] = address(attester2.addr);

registry.check(address(module1), ModuleType.wrap(1), attester1.addr);
registry.check(address(module1), ModuleType.wrap(2), attester1.addr);
vm.expectRevert();
registry.check(address(module1), ModuleType.wrap(3), attester1.addr);
registry.checkN(address(module1), trustedAttesters, 1);

}
}

0 comments on commit 629c25f

Please sign in to comment.