Skip to content

Commit 4028d1a

Browse files
authored
feat(ci): add Tempo test contract support files (foundry-rs#14205)
* feat(script): add `--tempo.fee-token` to `forge script` * feat(ci): add Tempo test contract support files
1 parent 845f807 commit 4028d1a

5 files changed

Lines changed: 106 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
contract BatchCounter {
5+
uint256 public number;
6+
7+
constructor(uint256 initialNumber) {
8+
number = initialNumber;
9+
}
10+
11+
function setNumber(uint256 newNumber) public {
12+
number = newNumber;
13+
}
14+
15+
function increment() public {
16+
number++;
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
6+
interface ICounter {
7+
function increment() external;
8+
function setNumber(uint256 newNumber) external;
9+
function number() external view returns (uint256);
10+
}
11+
12+
contract BatchRevertTestScript is Script {
13+
function run() public {
14+
address counter = ${REQUIRE_COUNTER};
15+
vm.startBroadcast();
16+
17+
// First call succeeds
18+
ICounter(counter).setNumber(600);
19+
// Second call fails (require > 100 fails with 50)
20+
ICounter(counter).setNumber(50);
21+
22+
vm.stopBroadcast();
23+
}
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
6+
interface ICounter {
7+
function increment() external;
8+
function setNumber(uint256 newNumber) external;
9+
function number() external view returns (uint256);
10+
}
11+
12+
contract BatchTestScript is Script {
13+
function run() public {
14+
address counter = ${REQUIRE_COUNTER};
15+
vm.startBroadcast();
16+
17+
// Multiple calls that will be batched into a single transaction
18+
ICounter(counter).setNumber(500);
19+
ICounter(counter).increment();
20+
ICounter(counter).increment();
21+
ICounter(counter).increment();
22+
23+
vm.stopBroadcast();
24+
}
25+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
contract Counter {
5+
uint256 public number;
6+
7+
function setNumber(uint256 newNumber) public {
8+
require(newNumber > 100, "bad number");
9+
number = newNumber;
10+
}
11+
12+
function increment() public {
13+
number++;
14+
}
15+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
import {Script, console} from "forge-std/Script.sol";
5+
import {BatchCounter} from "../src/BatchCounter.sol";
6+
7+
contract DeployAndCallScript is Script {
8+
function run() public {
9+
vm.startBroadcast();
10+
11+
// Deploy contract (CREATE as first call)
12+
BatchCounter counter = new BatchCounter(100);
13+
14+
// Call the newly deployed contract in the same batch
15+
counter.setNumber(200);
16+
counter.increment();
17+
counter.increment();
18+
19+
// Final number should be 202 (200 + 2 increments)
20+
console.log("Deployed BatchCounter at:", address(counter));
21+
22+
vm.stopBroadcast();
23+
}
24+
}

0 commit comments

Comments
 (0)