You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contracts/sei-tester/README.md
+152-2
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,160 @@ sei-chain integration in your smart contracts.
12
12
First we need deploy an EVM contract on the Sei chain. Let's use a simple counter contract and
13
13
foundry tooling to deploy it.
14
14
15
-
Install the [foundry tooling](https://book.getfoundry.sh/) by following this [guide](https://book.getfoundry.sh/getting-started/installation.html).
15
+
Install the [foundry tooling](https://book.getfoundry.sh/) by following this [installation guide](https://book.getfoundry.sh/getting-started/installation.html).
16
16
17
-
```shell
17
+
18
+
Create a new project following the [Creating New Project Guide](https://book.getfoundry.sh/projects/creating-a-new-project).
19
+
20
+
Once project is created, tweak the contract code to the following, by adding a `getCounter` function:
18
21
19
22
```solidity
23
+
// SPDX-License-Identifier: UNLICENSED
24
+
pragma solidity ^0.8.13;
25
+
26
+
contract Counter {
27
+
uint256 public number;
28
+
29
+
function setNumber(uint256 newNumber) public {
30
+
number = newNumber;
31
+
}
32
+
33
+
function increment() public {
34
+
number++;
35
+
}
36
+
37
+
function getCount() public view returns (uint256) {
38
+
return number;
39
+
}
40
+
}
41
+
42
+
```
43
+
44
+
And the test to the following:
45
+
```solidity
46
+
// SPDX-License-Identifier: UNLICENSED
47
+
pragma solidity ^0.8.13;
48
+
49
+
import {Test, console} from "forge-std/Test.sol";
50
+
import {Counter} from "../src/Counter.sol";
51
+
52
+
contract CounterTest is Test {
53
+
Counter public counter;
54
+
55
+
function setUp() public {
56
+
counter = new Counter();
57
+
counter.setNumber(0);
58
+
}
59
+
60
+
function test_Increment() public {
61
+
counter.increment();
62
+
assertEq(counter.number(), 1);
63
+
}
20
64
65
+
function testFuzz_SetNumber(uint256 x) public {
66
+
counter.setNumber(x);
67
+
assertEq(counter.number(), x);
68
+
}
69
+
70
+
function test_GetCount() public {
71
+
uint256 initialCount = counter.getCount();
72
+
counter.increment();
73
+
assertEq(counter.getCount(), initialCount + 1);
74
+
}
75
+
}
76
+
```
77
+
Run the tests with the following command:
78
+
```shell
79
+
forge test
80
+
```
81
+
If tests pass, deploy the contract to the Sei chain with the following command:
use sei_cosmwasm::{BulkOrderPlacementsResponse,Cancellation,DenomAuthorityMetadataResponse,DenomUnit,DenomsFromCreatorResponse,DepositInfo,DexTwapsResponse,EpochResponse,EvmAddressResponse,ExchangeRatesResponse,GetLatestPriceResponse,GetOrderByIdResponse,GetOrdersResponse,Metadata,MsgPlaceOrdersResponse,OracleTwapsResponse,Order,OrderSimulationResponse,OrderType,PositionDirection,SeiAddressResponse,SeiMsg,SeiQuerier,SeiQueryWrapper,SettlementEntry,SudoMsg,StaticCallResponse};
Copy file name to clipboardExpand all lines: contracts/sei-tester/tests/sei_tester_integration_tests.rs
+7-4
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,4 @@
1
+
use base64::{Engineas _, engine::{general_purpose}};
1
2
use cosmwasm_std::{
2
3
coin, from_json,
3
4
testing::{MockApi,MockStorage},
@@ -10,7 +11,7 @@ use cw_multi_test::{
10
11
StakeKeeper,WasmKeeper,
11
12
};
12
13
13
-
use sei_cosmwasm::{Cancellation,DenomOracleExchangeRatePair,DexPair,DexTwap,DexTwapsResponse,EpochResponse,EvmAddressResponse,ExchangeRatesResponse,GetOrderByIdResponse,GetOrdersResponse,OracleExchangeRate,OracleTwapsResponse,Order,OrderSimulationResponse,OrderStatus,OrderType,PositionDirection,SeiAddressResponse,SeiMsg,SeiQuery,SeiQueryWrapper,SeiRoute};
14
+
use sei_cosmwasm::{Cancellation,DenomOracleExchangeRatePair,DexPair,DexTwap,DexTwapsResponse,EpochResponse,EvmAddressResponse,ExchangeRatesResponse,GetOrderByIdResponse,GetOrdersResponse,OracleExchangeRate,OracleTwapsResponse,Order,OrderSimulationResponse,OrderStatus,OrderType,PositionDirection,SeiAddressResponse,SeiMsg,SeiQuery,SeiQueryWrapper,SeiRoute,StaticCallResponse};
use sei_cosmwasm::{Cancellation,DenomOracleExchangeRatePair,DexPair,DexTwap,DexTwapsResponse,Epoch,EpochResponse,EvmAddressResponse,ExchangeRatesResponse,GetOrderByIdResponse,GetOrdersResponse,OracleTwap,OracleTwapsResponse,Order,OrderResponse,OrderSimulationResponse,OrderStatus,PositionDirection,SeiAddressResponse,SeiMsg,SeiQuery,SeiQueryWrapper,StaticCallResponse,SudoMsgasSeiSudoMsg};
15
9
use serde::de::DeserializeOwned;
16
10
use std::{
17
11
collections::HashMap,
18
12
fmt::Debug,
19
13
ops::{Add,Div,Mul,Sub},
20
14
};
15
+
use base64::{Engineas _, engine::{general_purpose}};
0 commit comments