Skip to content

Commit 70d81a7

Browse files
committed
test: fixed VeaMock to account for some encoding mismatch
1 parent 35ac2cc commit 70d81a7

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

contracts/src/gateway/mock/VeaMock.sol

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "@kleros/vea-contracts/interfaces/IFastBridgeReceiver.sol";
77

88
contract VeaMock is IFastBridgeSender, IFastBridgeReceiver {
99
/* solhint-disable */
10+
1011
// ************************************* //
1112
// * Function Modifiers * //
1213
// ************************************* //
@@ -18,7 +19,17 @@ contract VeaMock is IFastBridgeSender, IFastBridgeReceiver {
1819
* @param _calldata The receiving domain encoded message data.
1920
*/
2021
function sendFast(address _receiver, bytes memory _calldata) external {
21-
_receiver.call(_calldata);
22+
// Dirty workaround: Solidity does not support array slices for memory arrays and the sender interface cannot be changed.
23+
(bytes4 selector, bytes memory payload) = this.decode(_calldata);
24+
25+
bytes32 sender = bytes32(uint256(uint160(msg.sender)));
26+
bytes memory data = abi.encodePacked(selector, sender, payload);
27+
(bool success, bytes memory res) = _receiver.call(data);
28+
require(success, "Call failure");
29+
}
30+
31+
function decode(bytes calldata data) external pure returns (bytes4, bytes memory) {
32+
return (bytes4(data[:4]), data[4:]);
2233
}
2334

2435
/**

contracts/test/integration/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe("Integration tests", async () => {
110110
});
111111
const tx = await arbitrable.createDispute(2, "0x00", 0, { value: arbitrationCost });
112112
const trace = await network.provider.send("debug_traceTransaction", [tx.hash]);
113-
const [disputeId] = ethers.utils.defaultAbiCoder.decode(["uint"], `0x${trace.returnValue}`);
113+
const [disputeId] = ethers.utils.defaultAbiCoder.decode(["uint"], `0x${trace.returnValue}`); // get returned value from createDispute()
114114
console.log("Dispute Created");
115115
expect(tx).to.emit(foreignGateway, "DisputeCreation");
116116
expect(tx).to.emit(foreignGateway, "OutgoingDispute");
@@ -179,7 +179,7 @@ describe("Integration tests", async () => {
179179

180180
const tx4 = await core.executeRuling(0);
181181
console.log("Ruling executed on KlerosCore");
182-
expect(tx4).to.emit(arbitrable, "Ruling");
182+
expect(tx4).to.emit(arbitrable, "Ruling").withArgs(foreignGateway.address, 1, 0);
183183
});
184184

185185
async function mineBlocks(n) {

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,11 +2383,11 @@ __metadata:
23832383
linkType: hard
23842384

23852385
"@kleros/vea-contracts@npm:dev":
2386-
version: 0.1.3
2387-
resolution: "@kleros/vea-contracts@npm:0.1.3"
2386+
version: 0.1.9
2387+
resolution: "@kleros/vea-contracts@npm:0.1.9"
23882388
dependencies:
23892389
"@openzeppelin/contracts": ^4.8.0
2390-
checksum: 3ab8e03ed81b14c868850fc213681070bbd10931bb31a845a01d6636d3ec080c4533e48a848c405b1d59dbac0d8f5647f84212ca5e23099fe3744fa9ee1484c2
2390+
checksum: 191014204d21e832d55b9f50cffc07657a4e5d7e907fbe134b4b11f6ad53b92bff959b80d41c388e088d2c01c60c470bd7b115fd7a612c20fbd770fbdf31f90c
23912391
languageName: node
23922392
linkType: hard
23932393

0 commit comments

Comments
 (0)