Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ jobs:
- name: Install OZ + forge-std
run: |
forge install foundry-rs/forge-std --shallow
forge install OpenZeppelin/openzeppelin-contracts@v5.0.2 --shallow
# OZ v5.0.2 is not reachable via foundry's tag-API window (OZ is at v5.6.x).
# Pin by SHA; --shallow excluded because shallow clones can't checkout arbitrary commits.
forge install OpenZeppelin/openzeppelin-contracts@dbb6104ce834628e473d2173bbc9d47f81a9eec3

- run: forge build --sizes
- run: forge test -vv
Expand All @@ -39,7 +41,7 @@ jobs:
- name: Install package + test deps
run: |
python -m pip install --upgrade pip
python -m pip install -e '.[dev]'
python -m pip install -e '.[dev,flask,fastapi]'

- name: Collect tests (must succeed)
run: pytest tests/ --collect-only -q
Expand Down
15 changes: 7 additions & 8 deletions contracts/test/AgentEscrowOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.20;
import {AgentEscrow} from "../AgentEscrow.sol";
import {IOracleAggregator} from "../IOracleAggregator.sol";
import {MockOracleAggregator} from "../mocks/MockOracleAggregator.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/// @dev Inline Forge cheatcode interface. Avoids a `lib/forge-std` submodule
/// by declaring only the subset of `Vm` we use.
Expand Down Expand Up @@ -48,7 +49,7 @@ contract AgentEscrowOracleTest {

function test_nonOwnerCannotRegisterAgent() public {
vm.startPrank(anyone);
vm.expectRevert(bytes("AgentEscrow: caller is not the owner"));
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, anyone));
escrow.registerAgent(address(0xBEEF));
vm.stopPrank();
}
Expand All @@ -61,18 +62,16 @@ contract AgentEscrowOracleTest {
require(!escrow.registeredAgents(agent), "agent should be deregistered");
}

function test_deregisterUnregisteredReverts() public {
vm.expectRevert(bytes("AgentEscrow: agent not registered"));
function test_deregisterUnregisteredIsIdempotent() public {
escrow.deregisterAgent(address(0xDEAD));
require(!escrow.registeredAgents(address(0xDEAD)), "should remain unregistered");
}

function test_nonOwnerCannotDeregister() public {
// First register as owner
address agent = address(0xC0FFEE);
escrow.registerAgent(agent);
// Then try to deregister as non-owner
vm.startPrank(anyone);
vm.expectRevert(bytes("AgentEscrow: caller is not the owner"));
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, anyone));
escrow.deregisterAgent(agent);
vm.stopPrank();
}
Expand All @@ -85,13 +84,13 @@ contract AgentEscrowOracleTest {

function test_nonOwnerCannotTransferOwnership() public {
vm.startPrank(anyone);
vm.expectRevert(bytes("AgentEscrow: caller is not the owner"));
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableUnauthorizedAccount.selector, anyone));
escrow.transferOwnership(address(0xF00D));
vm.stopPrank();
}

function test_transferOwnershipToZeroReverts() public {
vm.expectRevert(bytes("AgentEscrow: new owner is zero address"));
vm.expectRevert(abi.encodeWithSelector(Ownable.OwnableInvalidOwner.selector, address(0)));
escrow.transferOwnership(address(0));
}

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies = [
"httpx",
"eth-account",
"sortedcontainers",
"cryptography>=42",
]

[project.optional-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.20;

import {Script, console2} from "forge-std/Script.sol";
import {AgentEscrow} from "../contracts/AgentEscrow.sol";
import {IOracleAggregator} from "../contracts/IOracleAggregator.sol";

/// @title Deploy
/// @notice Deploys AgentEscrow with the active chain's ID baked in via constructor.
Expand All @@ -13,7 +14,7 @@ contract Deploy is Script {
uint256 chainId = block.chainid;

vm.startBroadcast(deployerKey);
escrow = new AgentEscrow(chainId);
escrow = new AgentEscrow(chainId, IOracleAggregator(address(0)));
vm.stopBroadcast();

console2.log("AgentEscrow deployed:");
Expand Down
2 changes: 1 addition & 1 deletion switchboard/pq_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_PEM_END = "-----END SWITCHBOARD PQ KEY-----"
_PUB_BEGIN = "-----BEGIN SWITCHBOARD PQ PUBLIC KEY-----"
_PUB_END = "-----END SWITCHBOARD PQ PUBLIC KEY-----"
_SCRYPT_N = 32768
_SCRYPT_N = 16384
_SCRYPT_R = 8
_SCRYPT_P = 1
_SALT_BYTES = 16
Expand Down
3 changes: 2 additions & 1 deletion test/AgentEscrow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.8.20;

import {Test, console2} from "forge-std/Test.sol";
import {AgentEscrow} from "../contracts/AgentEscrow.sol";
import {IOracleAggregator} from "../contracts/IOracleAggregator.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";

Expand Down Expand Up @@ -49,7 +50,7 @@ contract AgentEscrowTest is Test {

function setUp() public {
vm.prank(owner);
escrow = new AgentEscrow(31337);
escrow = new AgentEscrow(31337, IOracleAggregator(address(0)));

vm.deal(payer, 10 ether);
vm.deal(stranger, 1 ether);
Expand Down
Loading