Commit f2ef2a0f authored by clabby's avatar clabby

streamline

parent 2fbec5b8
...@@ -443,40 +443,34 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init { ...@@ -443,40 +443,34 @@ contract FaultDisputeGame_Test is FaultDisputeGame_Init {
FaultDisputeGame.OutputProposal memory disputed FaultDisputeGame.OutputProposal memory disputed
) = gameProxy.proposals(); ) = gameProxy.proposals();
// Load the L1 head hash bytes32[5] memory data = [
gameProxy.addLocalData(1, 8); Hash.unwrap(gameProxy.l1Head()),
bytes32 key = _getKey(1); Hash.unwrap(starting.outputRoot),
(bytes32 dat, uint256 datLen) = oracle.readPreimage(key, 8); Hash.unwrap(disputed.outputRoot),
assertEq(dat, Hash.unwrap(gameProxy.l1Head())); bytes32(uint256(starting.l2BlockNumber) << 0xC0),
assertEq(datLen, 32); bytes32(block.chainid << 0xC0)
];
// Load the starting output root
gameProxy.addLocalData(2, 8); for (uint256 i = 1; i <= 5; i++) {
key = _getKey(2); uint256 expectedLen = i > 3 ? 8 : 32;
(dat, datLen) = oracle.readPreimage(key, 8);
assertEq(dat, Hash.unwrap(starting.outputRoot)); gameProxy.addLocalData(i, 0);
assertEq(datLen, 32); bytes32 key = _getKey(i);
(bytes32 dat, uint256 datLen) = oracle.readPreimage(key, 0);
// Load the disputed output root assertEq(dat >> 0xC0, bytes32(expectedLen));
gameProxy.addLocalData(3, 8); // Account for the length prefix if i > 3 (the data stored
key = _getKey(3); // at identifiers i <= 3 are 32 bytes long, so the expected
(dat, datLen) = oracle.readPreimage(key, 8); // length is already correct. If i > 3, the data is only 8
assertEq(dat, Hash.unwrap(disputed.outputRoot)); // bytes long, so the length prefix + the data is 16 bytes
assertEq(datLen, 32); // total.)
assertEq(datLen, expectedLen + (i > 3 ? 8 : 0));
// Load the starting L2 block number
gameProxy.addLocalData(4, 8); gameProxy.addLocalData(i, 8);
key = _getKey(4); key = _getKey(i);
(dat, datLen) = oracle.readPreimage(key, 8); (dat, datLen) = oracle.readPreimage(key, 8);
assertEq(dat, bytes32(uint256(starting.l2BlockNumber) << 0xC0)); assertEq(dat, data[i - 1]);
assertEq(datLen, 8); assertEq(datLen, expectedLen);
}
// Load the chain ID
gameProxy.addLocalData(5, 8);
key = _getKey(5);
(dat, datLen) = oracle.readPreimage(key, 8);
assertEq(dat, bytes32(block.chainid << 0xC0));
assertEq(datLen, 8);
} }
/// @dev Helper to get the localized key for an identifier in the context of the game proxy. /// @dev Helper to get the localized key for an identifier in the context of the game proxy.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment