Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/use-TestSetRealm-in-testcases #239

Merged
merged 2 commits into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ $ export WORKDIR=~/work

### Build Gno.land for Gnoswap

Clone the `gno` repository from `gnoswap-labs`. And switch to the `master_20240401` branch. You will be able to clone the repository and build it after running the following commands:
Clone the `gno` repository from `gnoswap-labs`. And switch to the `master_240619` branch. You will be able to clone the repository and build it after running the following commands:

```
$ cd $WORKDIR
$ git clone https://github.com/gnoswap-labs/gno.git gno
$ cd gno
$ git checkout master_gs
$ git checkout master_240619
$ make install
```

Expand Down
29 changes: 0 additions & 29 deletions go.mod

This file was deleted.

140 changes: 0 additions & 140 deletions go.sum

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ var (
maxApprove uint64 = 18446744073709551615
)

// Realms to mock frames
var (
gsaRealm = std.NewUserRealm(gsa)
posRealm = std.NewCodeRealm(consts.POSITION_PATH)
rouRealm = std.NewCodeRealm(consts.ROUTER_PATH)
)

/* HELPER */
func shouldEQ(t *testing.T, got, expected interface{}) {
if got != expected {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ var (
t *testing.T
)

var (
gsaRealm = std.NewUserRealm(gsa)
posRealm = std.NewCodeRealm(consts.POSITION_PATH)
rouRealm = std.NewCodeRealm(consts.ROUTER_PATH)
)

type FooToken struct{}

func (FooToken) Transfer() func(to pusers.AddressOrName, amount uint64) {
Expand Down Expand Up @@ -149,10 +155,12 @@ func (GNSToken) Approve() func(spender pusers.AddressOrName, amount uint64) {
}

func init() {
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)

// TOKEN REGISTER
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)
std.TestSetOrigCaller(gsa)

pl.RegisterGRC20Interface("gno.land/r/demo/bar", FooToken{})
pl.RegisterGRC20Interface("gno.land/r/demo/foo", BarToken{})
pl.RegisterGRC20Interface("gno.land/r/demo/baz", BazToken{})
Expand All @@ -173,7 +181,7 @@ func main() {
}

func createFooBarPool() {
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)

gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(1)
Expand All @@ -186,7 +194,7 @@ func createFooBarPool() {
}

func createBarBazPool() {
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)

gns.Approve(a2u(consts.POOL_ADDR), consts.POOL_CREATION_FEE)
std.TestSkipHeights(1)
Expand All @@ -199,12 +207,12 @@ func createBarBazPool() {
}

func mintFooBar() {
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)
foo.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)
bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)
std.TestSkipHeights(2)

//std.TestSetPrevRealm(consts.POSITION_PATH)
//std.TestSetRealm(posRealm)
//std.TestSetOrigCaller(gsa)
amount0, amount1 := pl.Mint(
barPath,
Expand All @@ -224,12 +232,12 @@ func mintFooBar() {
}

func mintBarBaz() {
std.TestSetPrevAddr(gsa)
std.TestSetRealm(gsaRealm)
bar.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)
baz.Approve(a2u(consts.POOL_ADDR), consts.UINT64_MAX)
std.TestSkipHeights(2)

//std.TestSetPrevRealm(consts.POSITION_PATH)
//std.TestSetRealm(posRealm)
//std.TestSetOrigCaller(gsa)
amount0, amount1 := pl.Mint(
barPath,
Expand Down
Loading