Skip to content

Commit

Permalink
fix: warnings for test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
nakul1010 committed Feb 7, 2024
1 parent 4cc1646 commit 3b1a237
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:

- name: Run Forge tests
run: |
forge test -vvv --via-ir
forge test -vvv --via-ir --deny-warnings
id: test

- name: Run Forge docs
Expand Down
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ src = "src"
out = "out"
libs = ["lib"]
solc = "0.8.17"

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

remappings = [
Expand Down
4 changes: 2 additions & 2 deletions test/BitcoinTx.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract BitcoinTxTest is Test {
assertEq(txHash, hex"76f251d17d821b938e39b508cd3e02233d71d9b9bfe387a42a050023d3788edb");
}

function test_EnsureTxInputSpendsUtxo() public {
function test_EnsureTxInputSpendsUtxo() public pure {
bytes memory inputVector =
hex"063941cf4ed4dad655dcbbf363347f2ddd3eb8851991c9f4f635cfe2a26ef2498f0d000000fc00473044022035a1616b0c034a9a17aaa409a60049b4da34148ebc84b97750b20b28a67751230220580a8bac27e7e31675adcbcc27937389d1f35c976d41f9dde0e62de4c94e38260147304402200cb5d3dbc523da3a99ca4da0fc8ba35d3266939a6c6eb6e6ba70979fc9c1e93302201e91fcc95928da5e01ccc5127000a792d407987503ef59e55d07b7bdb720eefb014c69522103cbc6a30564adc716a52fc28a9ead7b06611765f6f9ecd90d19567033ed9b01b421034c939adc400e67354b4df6afcbedea2a3dc5a4c4805631426363f2fcffd709bd210270fec2b3df4961de8a5e10febb3319922b288efa1300cf048752f3a413a44e1553aefffffffff81c0fe333bc864e0c9d1b32a1dcc14352694dabb015fb6c35f9fc2f0e32ca9d00000000fdfd00004830450221009cf1afe74a98a37798b7324fd2871410b2e269c14aeb05968ca8ce1f23ebe1b4022024164457fcbac57c978dba1bc3ae53378f26aa5380d1bec975da4f85ff9c16ea01473044022042f5950266ad1be284c7ec10d7ca4e7b6cdfbec0c009c5f73f2bdbd24e85eb2902203ac84a337b6e4448a6f7e5d6720e513deefa52a3bb11ce58255756fc9ab48dfe014c695221037fe3f1cffadb5a78862ec191411a824dbc6fbc162db232cc54c845d08527a8922102e983bee0d7339993c6c64ec038a3a576fe3f71b90471a35b22f566fbdefe00e92103bb54d778d8a51d87ddbadb81930c24c316be852cc8b8b3ada9ff50c70e19c9b553aeffffffffab937ce4cf7db7259523eb70e3a2534fae8c899bf101c96eca826caa8dbb44650000000000ffffffff405eaef05128f2d4b1af6fbf7f8584b6d9937b67f18e0f73c4bc1cdf2d6280ec00000000fdfd0000483045022100aba3ac85c6f81fb692cb1227b0a525514e8d6eb46f89a4f407e547dc70b89a5b02207cec256fedfa4407a96eefdb413f79618b3d199677e2b1031a5d66008e7346b701473044022072dc0e1f6208fde1d9a94d14ac945eec6b018af9857ba2f8c5e3df9ae694070e02207328cbeae5be5680152d6b7ab1c706dd3f3098977a94cc12458a44be7b804b58014c69522103a780028aebbf4948a667fc13c7d65926b584aa89d6dcf7f5ea2781f536c99b612103f336f404719f79111f4b06589de871fc9cb7da49a03d02da36dbeb046554c4752102200acc243b2f9d8b84369a28732236c2df0709d59b1199a0a451d332b4fc93c453aeffffffff977ca6132acad11a89ceae92ea15a540ae5366f19f871a61fb6ae6b4daa5b52f00000000fdfd00004730440220352b828c387a78968cb945cca1c7001397dbb5aa723ca817159e5237ec1d69e902201059d50234972874a2aff4473baf53657e8779fb360c83770ab6305b55836720014830450221008a71067a4a4e8acca22ac59bf91d14c4d25e8693a50fbf79ff7cc392e75d2bd5022079b7a6e3f663cb443cf3e2c512176ab36b96b5ee0c03ffbe05f4404f7ed2e338014c69522102fca18dc12a5f3d1dae0a3e76d77f5f79b89d76cbb24e861c7d982be60dd4bf5d210274627fee4ab8e5953b183ddc7edbd45488e4d6faf9df9c640e05035c4af9ec5c210291ed80108c6fb853de2e4f993c7b63a8a5935ee03ac90fed8cdd1b8725c5a7b253aefffffffff00c97eb214c453a7f51b55182d448cd410dc937dbfd967135548a8a2a1f7ade00000000fdfd000047304402200645636f91c792d54346a589d021fbfb7af8803f3d8feaff2f4cd1f2e703f6dc02205eb48fa9428b6e7d1d03bc1788025ff1da58a686903e46386929ce8f810064af01483045022100b32407c41ce04d92976ebfb55018a3cf6b9bf00315c21b29c237f18e0e4f4eec022063de776c5cbdf4d3322a5229bfbea21ec12bd5470c5423cd612c4ca2f823efc4014c69522103f570642ab999a8ccaccf6d275aabb24db32907e1a37b62ab6271865c5a8194ac2103cf7901f7a585cf32aa1d9024807639540062afba94fd466f7b50417e22376d6b2102c5fa500865c57f92204a28326d126fa8eba13a0b43f860ba1eb0d4b44ce5c47c53aeffffffff";
BitcoinTx.UTXO memory utxo2;
Expand Down Expand Up @@ -79,7 +79,7 @@ contract BitcoinTxTest is Test {
BitcoinTx.ensureTxInputSpendsUtxo(inputVector, utxo);
}

function test_ensureTxInputSpendsUtxoReadOverrun() public {
function test_EnsureTxInputSpendsUtxoReadOverrun() public {
bytes memory inputVector = hex"ff";
BitcoinTx.UTXO memory utxo;
vm.expectRevert("Read overrun during VarInt parsing");
Expand Down
37 changes: 16 additions & 21 deletions test/LightRelay.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ contract LightRelayTest is Test {
}

function test_ValidateHeaderChainsEpoch274() public {
(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[1].data, retargetHeaders[2].data, retargetHeaders[3].data, retargetHeaders[4].data
)
Expand All @@ -453,14 +453,14 @@ contract LightRelayTest is Test {
}

function test_ValidateShortHeaderChainsEpoch274() public {
(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(retargetHeaders[1].data, retargetHeaders[2].data, retargetHeaders[3].data)
);
assertEq(headerCount, 3);
}

function test_ValidateLongHeaderChainsEpoch274() public {
(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[1].data,
retargetHeaders[2].data,
Expand All @@ -478,21 +478,18 @@ contract LightRelayTest is Test {

function test_ValidateChainShouldRejectSingleHeaderAfterEpoch274() public {
vm.expectRevert("Invalid number of headers");
(uint256 startingHeaderTimestamp, uint256 headerCount) =
relay.validateChain(abi.encodePacked(retargetHeaders[0].data));
relay.validateChain(abi.encodePacked(retargetHeaders[0].data));
}

function test_ValidateChainShouldRejectUnknownRetargetAfterEpoch274() public {
vm.expectRevert("Invalid number of headers");
(uint256 startingHeaderTimestamp, uint256 headerCount) =
relay.validateChain(abi.encodePacked(retargetHeaders[0].data));
relay.validateChain(abi.encodePacked(retargetHeaders[0].data));
}

function test_ValidateChainShouldRejectChainInFutureEpochAfterEpoch274() public {
setUpGenesis();
vm.expectRevert("Invalid target in header chain");

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
relay.validateChain(
abi.encodePacked(
retargetHeaders[10].data, retargetHeaders[11].data, retargetHeaders[12].data, retargetHeaders[13].data
)
Expand All @@ -502,7 +499,7 @@ contract LightRelayTest is Test {
function test_ValidateHeaderChainsAfterEpoch275() public {
relay = new LightRelay();
relay.genesis(nextStartHeader.data, nextStartHeader.height, 4);
(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[10].data, retargetHeaders[11].data, retargetHeaders[12].data, retargetHeaders[13].data
)
Expand All @@ -514,8 +511,7 @@ contract LightRelayTest is Test {
relay = new LightRelay();
relay.genesis(nextStartHeader.data, nextStartHeader.height, 4);
vm.expectRevert("Cannot validate chains before relay genesis");

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
relay.validateChain(
abi.encodePacked(
retargetHeaders[9].data, retargetHeaders[10].data, retargetHeaders[11].data, retargetHeaders[12].data
)
Expand All @@ -526,8 +522,7 @@ contract LightRelayTest is Test {
relay = new LightRelay();
relay.genesis(nextStartHeader.data, nextStartHeader.height, 4);
vm.expectRevert("Cannot validate chains before relay genesis");

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
relay.validateChain(
abi.encodePacked(
retargetHeaders[6].data, retargetHeaders[7].data, retargetHeaders[8].data, retargetHeaders[9].data
)
Expand All @@ -536,7 +531,7 @@ contract LightRelayTest is Test {

function test_ValidateHeaderChainsAfterGenesisEpoch() public {
setUpGenesis();
(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[1].data, retargetHeaders[2].data, retargetHeaders[3].data, retargetHeaders[4].data
)
Expand All @@ -560,7 +555,7 @@ contract LightRelayTest is Test {
)
);

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[7].data, retargetHeaders[8].data, retargetHeaders[9].data, retargetHeaders[10].data
)
Expand All @@ -584,7 +579,7 @@ contract LightRelayTest is Test {
)
);

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[8].data, retargetHeaders[9].data, retargetHeaders[10].data, retargetHeaders[11].data
)
Expand All @@ -608,7 +603,7 @@ contract LightRelayTest is Test {
)
);

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
retargetHeaders[9].data, retargetHeaders[10].data, retargetHeaders[11].data, retargetHeaders[12].data
)
Expand All @@ -620,7 +615,7 @@ contract LightRelayTest is Test {
relay = new LightRelay();
relay.genesis(postRetargetChain[0].data, postRetargetChain[0].height, 8);

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
(, uint256 headerCount) = relay.validateChain(
abi.encodePacked(
postRetargetChain[0].data,
postRetargetChain[1].data,
Expand All @@ -640,7 +635,7 @@ contract LightRelayTest is Test {
relay.genesis(postRetargetChain[0].data, postRetargetChain[0].height, 8);
vm.expectRevert("Invalid chain");

(uint256 startingHeaderTimestamp, uint256 headerCount) = relay.validateChain(
relay.validateChain(
abi.encodePacked(
postRetargetChain[1].data,
postRetargetChain[2].data,
Expand Down Expand Up @@ -828,7 +823,7 @@ contract LightRelayTest is Test {
state.txProofDifficultyFactor = 1;

// txId = 15afe550f468cf0134557533e7f0bd6f210c1a2791d75a8ea57f17c4209448f9
(bytes32 txHash) = state.validateProof(
state.validateProof(
BitcoinTx.Info({
version: hex"02000000",
inputVector: hex"01123c43f161517343e93191e838b2f04356665ff526bf95cfe6c9986de7a10a3e010000001716001402c8f68bb02b257de42f5ca11b525bd3b47a0369feffffff",
Expand Down

0 comments on commit 3b1a237

Please sign in to comment.