Skip to content

Commit

Permalink
Merge branch 'main' of github.com:rainlanguage/rain.flow into 2024-09…
Browse files Browse the repository at this point in the history
…-11-refactoring-FlowBasicTest
  • Loading branch information
Erikd-dev committed Sep 15, 2024
2 parents b490482 + e469884 commit d2c3b39
Show file tree
Hide file tree
Showing 16 changed files with 652 additions and 298 deletions.
6 changes: 6 additions & 0 deletions test/abstract/FlowBasicTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,15 @@ import {EvaluableV2} from "rain.interpreter.interface/lib/caller/LibEvaluable.so
import {CloneFactory} from "rain.factory/src/concrete/CloneFactory.sol";
import {LibUint256Matrix} from "rain.solmem/lib/LibUint256Matrix.sol";
import {LibLogHelper} from "test/lib/LibLogHelper.sol";
import {SignedContextV1} from "rain.interpreter.interface/interface/IInterpreterCallerV2.sol";
import {LibStackGeneration} from "test/lib/LibStackGeneration.sol";
import {Address} from "openzeppelin-contracts/contracts/utils/Address.sol";

abstract contract FlowBasicTest is FlowUtilsAbstractTest, InterpreterMockTest {
using LibUint256Matrix for uint256[];
using LibLogHelper for Vm.Log[];
using LibStackGeneration for uint256;
using Address for address;

CloneFactory internal immutable iCloneFactory;
address internal iFlowImplementation;
Expand Down Expand Up @@ -119,6 +124,7 @@ abstract contract FlowBasicTest is FlowUtilsAbstractTest, InterpreterMockTest {
vm.assume(account != address(vm));
vm.assume(sentinel != uint256(uint160(account)));
vm.assume(account != address(expression));
vm.assume(!account.isContract());
// The console.
vm.assume(account != address(0x000000000000000000636F6e736F6c652e6c6f67));
}
Expand Down
56 changes: 28 additions & 28 deletions test/concrete/flowBasic/FlowPreviewTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ contract FlowPreviewTest is FlowBasicTest {
function testFlowBasePreviewDefinedFlowIOForERC1155MultiElementArrays(
address alice,
uint256 erc1155OutTokenIdA,
uint256 erc1155OutAmmountA,
uint256 erc1155OutAmountA,
uint256 erc1155InTokenIdB,
uint256 erc1155InAmmountB
uint256 erc1155InAmountB
) external {
vm.assume(sentinel != erc1155OutTokenIdA);
vm.assume(sentinel != erc1155OutAmmountA);
vm.assume(sentinel != erc1155OutAmountA);
vm.assume(sentinel != erc1155InTokenIdB);
vm.assume(sentinel != erc1155InAmmountB);
vm.assume(sentinel != erc1155InAmountB);
vm.label(alice, "alice");

(IFlowV5 flow,) = deployFlow();
Expand All @@ -38,31 +38,31 @@ contract FlowPreviewTest is FlowBasicTest {
from: address(flow),
to: alice,
id: erc1155OutTokenIdA,
amount: erc1155OutAmmountA
amount: erc1155OutAmountA
});

erc1155Transfers[1] = ERC1155Transfer({
token: address(iTokenB),
from: address(flow),
to: alice,
id: erc1155InTokenIdB,
amount: erc1155InAmmountB
amount: erc1155InAmountB
});

erc1155Transfers[2] = ERC1155Transfer({
token: address(iTokenA),
from: alice,
to: address(flow),
id: erc1155OutTokenIdA,
amount: erc1155OutAmmountA
amount: erc1155OutAmountA
});

erc1155Transfers[3] = ERC1155Transfer({
token: address(iTokenB),
from: alice,
to: address(flow),
id: erc1155InTokenIdB,
amount: erc1155InAmmountB
amount: erc1155InAmountB
});

FlowTransferV1 memory flowTransfer =
Expand Down Expand Up @@ -114,11 +114,11 @@ contract FlowPreviewTest is FlowBasicTest {
*/
function testFlowBasePreviewDefinedFlowIOForERC20MultiElementArrays(
address alice,
uint256 erc20AmmountA,
uint256 erc20AmmountB
uint256 erc20AmountA,
uint256 erc20AmountB
) external {
vm.assume(sentinel != erc20AmmountA);
vm.assume(sentinel != erc20AmmountB);
vm.assume(sentinel != erc20AmountA);
vm.assume(sentinel != erc20AmountB);

vm.label(alice, "alice");

Expand All @@ -127,13 +127,13 @@ contract FlowPreviewTest is FlowBasicTest {

ERC20Transfer[] memory erc20Transfers = new ERC20Transfer[](4);
erc20Transfers[0] =
ERC20Transfer({token: address(iTokenA), from: address(flow), to: alice, amount: erc20AmmountA});
ERC20Transfer({token: address(iTokenA), from: address(flow), to: alice, amount: erc20AmountA});
erc20Transfers[1] =
ERC20Transfer({token: address(iTokenB), from: address(flow), to: alice, amount: erc20AmmountB});
ERC20Transfer({token: address(iTokenB), from: address(flow), to: alice, amount: erc20AmountB});
erc20Transfers[2] =
ERC20Transfer({token: address(iTokenA), from: alice, to: address(flow), amount: erc20AmmountA});
ERC20Transfer({token: address(iTokenA), from: alice, to: address(flow), amount: erc20AmountA});
erc20Transfers[3] =
ERC20Transfer({token: address(iTokenB), from: alice, to: address(flow), amount: erc20AmmountB});
ERC20Transfer({token: address(iTokenB), from: alice, to: address(flow), amount: erc20AmountB});

FlowTransferV1 memory flowTransfer =
FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0));
Expand All @@ -152,14 +152,14 @@ contract FlowPreviewTest is FlowBasicTest {
function testFlowBasePreviewDefinedFlowIOForERC1155SingleElementArrays(
address alice,
uint256 erc1155OutTokenId,
uint256 erc1155OutAmmount,
uint256 erc1155OutAmount,
uint256 erc1155InTokenId,
uint256 erc1155InAmmount
uint256 erc1155InAmount
) external {
vm.assume(sentinel != erc1155OutTokenId);
vm.assume(sentinel != erc1155OutAmmount);
vm.assume(sentinel != erc1155OutAmount);
vm.assume(sentinel != erc1155InTokenId);
vm.assume(sentinel != erc1155InAmmount);
vm.assume(sentinel != erc1155InAmount);
vm.label(alice, "alice");

(IFlowV5 flow,) = deployFlow();
Expand All @@ -172,15 +172,15 @@ contract FlowPreviewTest is FlowBasicTest {
from: address(flow),
to: alice,
id: erc1155OutTokenId,
amount: erc1155OutAmmount
amount: erc1155OutAmount
});

erc1155Transfers[1] = ERC1155Transfer({
token: address(iTokenA),
from: alice,
to: address(flow),
id: erc1155InTokenId,
amount: erc1155InAmmount
amount: erc1155InAmount
});

FlowTransferV1 memory flowTransfer =
Expand Down Expand Up @@ -228,11 +228,11 @@ contract FlowPreviewTest is FlowBasicTest {
*/
function testFlowBasePreviewDefinedFlowIOForERC20SingleElementArrays(
address alice,
uint256 erc20AmmountIn,
uint256 erc20AmmountOut
uint256 erc20AmountIn,
uint256 erc20AmountOut
) external {
vm.assume(sentinel != erc20AmmountIn);
vm.assume(sentinel != erc20AmmountOut);
vm.assume(sentinel != erc20AmountIn);
vm.assume(sentinel != erc20AmountOut);

vm.label(alice, "alice");

Expand All @@ -241,9 +241,9 @@ contract FlowPreviewTest is FlowBasicTest {

ERC20Transfer[] memory erc20Transfers = new ERC20Transfer[](2);
erc20Transfers[0] =
ERC20Transfer({token: address(iTokenA), from: address(flow), to: alice, amount: erc20AmmountOut});
ERC20Transfer({token: address(iTokenA), from: address(flow), to: alice, amount: erc20AmountOut});
erc20Transfers[1] =
ERC20Transfer({token: address(iTokenA), from: alice, to: address(flow), amount: erc20AmmountIn});
ERC20Transfer({token: address(iTokenA), from: alice, to: address(flow), amount: erc20AmountIn});

FlowTransferV1 memory flowTransfer =
FlowTransferV1(erc20Transfers, new ERC721Transfer[](0), new ERC1155Transfer[](0));
Expand Down
Loading

0 comments on commit d2c3b39

Please sign in to comment.