mirror of
https://github.com/Instadapp/dsa-periphery-contract.git
synced 2024-07-29 22:27:13 +00:00
update unit test
This commit is contained in:
parent
9c24594311
commit
d33c5f2143
1896
cache_forge/solidity-files-cache.json
Normal file
1896
cache_forge/solidity-files-cache.json
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -23,13 +23,16 @@ contract MockInstadappReceiver is InstadappAdapter {
|
||||||
contract InstadappAdapterTest is TestHelper {
|
contract InstadappAdapterTest is TestHelper {
|
||||||
// ============ Storage ============
|
// ============ Storage ============
|
||||||
address dsa = address(1);
|
address dsa = address(1);
|
||||||
MockInstadappReceiver instadappReceiver;
|
address instadappReceiver = 0x5615dEB798BB3E4dFa0139dFa1b3D433Cc23b72f;
|
||||||
uint256 deadline = block.timestamp + 3600 seconds;
|
|
||||||
|
uint256 deadline = 100;
|
||||||
|
uint256 timestamp = 90;
|
||||||
|
|
||||||
// ============ Test set up ============
|
// ============ Test set up ============
|
||||||
function setUp() public override {
|
function setUp() public override {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
instadappReceiver = new MockInstadappReceiver();
|
MockInstadappReceiver _instadappReceiver = new MockInstadappReceiver();
|
||||||
|
vm.etch(instadappReceiver, address(_instadappReceiver).code);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Utils ============
|
// ============ Utils ============
|
||||||
|
@ -59,7 +62,7 @@ contract InstadappAdapterTest is TestHelper {
|
||||||
bytes32 salt = bytes32(abi.encode(1));
|
bytes32 salt = bytes32(abi.encode(1));
|
||||||
|
|
||||||
vm.expectRevert(bytes("Invalid Auth"));
|
vm.expectRevert(bytes("Invalid Auth"));
|
||||||
instadappReceiver.tryAuthCast(dsa, auth, signature, castData, salt, deadline);
|
MockInstadappReceiver(instadappReceiver).tryAuthCast(dsa, auth, signature, castData, salt, deadline);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_InstadappAdapter__authCast_shouldRevertIfInvalidSignature() public {
|
function test_InstadappAdapter__authCast_shouldRevertIfInvalidSignature() public {
|
||||||
|
@ -83,7 +86,7 @@ contract InstadappAdapterTest is TestHelper {
|
||||||
address auth = originSender;
|
address auth = originSender;
|
||||||
bytes32 salt = bytes32(abi.encode(1));
|
bytes32 salt = bytes32(abi.encode(1));
|
||||||
vm.expectRevert(bytes("Invalid signature"));
|
vm.expectRevert(bytes("Invalid signature"));
|
||||||
instadappReceiver.tryAuthCast(dsa, auth, signature, castData, salt, deadline);
|
MockInstadappReceiver(instadappReceiver).tryAuthCast(dsa, auth, signature, castData, salt, deadline);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_InstadappAdapter__authCast_shouldWork() public {
|
function test_InstadappAdapter__authCast_shouldWork() public {
|
||||||
|
@ -105,10 +108,11 @@ contract InstadappAdapterTest is TestHelper {
|
||||||
InstadappAdapter.CastData memory castData = InstadappAdapter.CastData(_targetNames, _datas, _origin);
|
InstadappAdapter.CastData memory castData = InstadappAdapter.CastData(_targetNames, _datas, _origin);
|
||||||
|
|
||||||
bytes
|
bytes
|
||||||
memory signature = hex"e06eb18ed5fa1258094a9af413275fc057cb5139b4e48c979a7ef9d028e8748e39bfa2ea23722f296a07ae7a2d2fee26c7de3ad067a2c569819bec0fc3c9f0f51b";
|
memory signature = hex"ac66d103e593be748af47496663fd93133970928dbfdade49bcca087d41773e95f4ead6a0897057adc61a67a6664de7730cc34055fdd500fded8c83b1e696fd61b";
|
||||||
|
|
||||||
address auth = originSender;
|
address auth = originSender;
|
||||||
instadappReceiver.tryAuthCast{value: 1}(dsa, auth, signature, castData, salt, deadline);
|
vm.warp(timestamp);
|
||||||
|
MockInstadappReceiver(instadappReceiver).tryAuthCast{value: 1}(dsa, auth, signature, castData, salt, deadline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ InstadappAdapter.verify ============
|
// ============ InstadappAdapter.verify ============
|
||||||
|
@ -131,10 +135,11 @@ contract InstadappAdapterTest is TestHelper {
|
||||||
InstadappAdapter.CastData memory castData = InstadappAdapter.CastData(_targetNames, _datas, _origin);
|
InstadappAdapter.CastData memory castData = InstadappAdapter.CastData(_targetNames, _datas, _origin);
|
||||||
|
|
||||||
bytes
|
bytes
|
||||||
memory signature = hex"e06eb18ed5fa1258094a9af413275fc057cb5139b4e48c979a7ef9d028e8748e39bfa2ea23722f296a07ae7a2d2fee26c7de3ad067a2c569819bec0fc3c9f0f51b";
|
memory signature = hex"ac66d103e593be748af47496663fd93133970928dbfdade49bcca087d41773e95f4ead6a0897057adc61a67a6664de7730cc34055fdd500fded8c83b1e696fd61b";
|
||||||
|
|
||||||
address auth = originSender;
|
address auth = originSender;
|
||||||
assertEq(instadappReceiver.verify(auth, signature, castData, salt, deadline), true);
|
vm.warp(timestamp);
|
||||||
|
assertEq(MockInstadappReceiver(instadappReceiver).verify(auth, signature, castData, salt, deadline), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_InstadappAdapter__verify_shouldReturnFalse() public {
|
function test_InstadappAdapter__verify_shouldReturnFalse() public {
|
||||||
|
@ -157,6 +162,6 @@ contract InstadappAdapterTest is TestHelper {
|
||||||
|
|
||||||
address auth = originSender;
|
address auth = originSender;
|
||||||
bytes32 salt = bytes32(abi.encode(1));
|
bytes32 salt = bytes32(abi.encode(1));
|
||||||
assertEq(instadappReceiver.verify(auth, signature, castData, salt, deadline), false);
|
assertEq(MockInstadappReceiver(instadappReceiver).verify(auth, signature, castData, salt, deadline), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user