Live-wiring (flip to production by config, no code change): - settlementProviderFromEnv (local/Circle) wired into every sidecar startSidecar - createFeedPoller fetches a live RSSHub JSON feed and ingests on an interval On-chain contracts (Foundry, Solc 0.8.30, forge test green): - RecursiveSplitDistributor.sol: settle a citation/remix lineage in one tx (RFB 6) - LeptonStreamSettlement.sol: per-second stream w/ reserve, proof-of-flow pause/resume, settle, close+refund (RFB 4) - AgentReputationBond.sol: ERC-8004-style USDC bond, release/slash (RFB 3) All green: full typecheck, 885 JS tests, 25 Foundry tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
1.7 KiB
Solidity
57 lines
1.7 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity ^0.8.20;
|
|
|
|
import {Test, MockERC20} from "./Helpers.sol";
|
|
import {AgentReputationBond} from "../src/AgentReputationBond.sol";
|
|
|
|
contract AgentReputationBondTest is Test {
|
|
MockERC20 internal usdc;
|
|
AgentReputationBond internal bond;
|
|
|
|
address internal broker = address(0xB80E2);
|
|
address internal client = address(0xC11E2);
|
|
address internal arbiter = address(0xA2B1);
|
|
bytes32 internal constant ID = keccak256("match-1");
|
|
|
|
function setUp() public {
|
|
usdc = new MockERC20();
|
|
bond = new AgentReputationBond(usdc);
|
|
usdc.mint(broker, 100);
|
|
vm.prank(broker);
|
|
usdc.approve(address(bond), 100);
|
|
}
|
|
|
|
function testPostHoldsTheBond() public {
|
|
vm.prank(broker);
|
|
bond.post(ID, client, arbiter, 50);
|
|
assertEq(usdc.balanceOf(address(bond)), 50);
|
|
assertEq(usdc.balanceOf(broker), 50);
|
|
}
|
|
|
|
function testReleaseReturnsToBroker() public {
|
|
vm.prank(broker);
|
|
bond.post(ID, client, arbiter, 50);
|
|
vm.prank(client);
|
|
bond.release(ID);
|
|
assertEq(usdc.balanceOf(broker), 100);
|
|
assertEq(usdc.balanceOf(address(bond)), 0);
|
|
}
|
|
|
|
function testSlashPaysClient() public {
|
|
vm.prank(broker);
|
|
bond.post(ID, client, arbiter, 50);
|
|
vm.prank(arbiter);
|
|
bond.slash(ID);
|
|
assertEq(usdc.balanceOf(client), 50);
|
|
assertEq(usdc.balanceOf(address(bond)), 0);
|
|
}
|
|
|
|
function testOnlyAuthorizedCanSlash() public {
|
|
vm.prank(broker);
|
|
bond.post(ID, client, arbiter, 50);
|
|
vm.prank(client); // client cannot slash (only broker/arbiter)
|
|
vm.expectRevert(AgentReputationBond.NotAuthorized.selector);
|
|
bond.slash(ID);
|
|
}
|
|
}
|