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

hotfix: terminate functions #214

Merged
merged 9 commits into from
May 2, 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
2 changes: 1 addition & 1 deletion __local/test/test_data.mk
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ swap-exact-in-multi-foo-to-gns-to-wugnot:
# approve OUTPUT TOKEN to ROUTER ( as 0.15% fee )
@echo "" | gnokey maketx call -pkgpath gno.land/r/demo/wugnot -func Approve -args $(ADDR_ROUTER) -args $(MAX_UINT64) -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 9000000 -memo "" gnoswap_tr01 > /dev/null

@echo "" | gnokey maketx call -pkgpath gno.land/r/demo/router -func SwapRoute -args "gno.land/r/demo/foo" -args "gno.land/r/demo/wugnot" -args 50000 -args "EXACT_IN" -args "gno.land/r/demo/foo:gno.land/r/demo/gns:500*POOL*gno.land/r/demo/gns:gno.land/r/demo/wugnot:500" -args "100" -args "1" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 10000000 -memo "" gnoswap_tr01 > /dev/null
@echo "" | gnokey maketx call -pkgpath gno.land/r/demo/router -func SwapRoute -args "gno.land/r/demo/foo" -args "gno.land/r/demo/wugnot" -args 50000 -args "EXACT_IN" -args "gno.land/r/demo/foo:gno.land/r/demo/gns:500*POOL*gno.land/r/demo/gns:gno.land/r/demo/wugnot:500" -args "100" -args "1" -insecure-password-stdin=true -remote $(GNOLAND_RPC_URL) -broadcast=true -chainid $(CHAINID) -gas-fee 1ugnot -gas-wanted 20000000 -memo "" gnoswap_tr01 > /dev/null
@echo

@$(MAKE) -f $(MAKEFILE) print-fee-collector
Expand Down
4 changes: 2 additions & 2 deletions _deploy/r/demo/gnoswap/common/allow_non_gnoswap_contracts.gno
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func MustCallFromAdmin() {
}

func DisallowCallFromUser() {
isOrigin := std.IsOriginCall()
if isOrigin {
prevRealmPath := std.PrevRealm().PkgPath()
if prevRealmPath == "" {
panic("must be called by realm, not user")
}
}
Expand Down
97 changes: 97 additions & 0 deletions gov/_TEST_/z_proposal_filetest.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package main

import (
"fmt"
"time"

"gno.land/r/demo/gov"
)

func main() {
TestSubmitProposal()

// CANNOT TEST THE FOLLOWING DUE TO THE LACK OF `process` FUNCTION in the integration filetest
// TestSubmitProposalFailedDeposit()
// TestSubmitProposalRejected(nil)
// TestSubmitProposalCommunityPoolSpend(nil)
// TestSubmitProposalMint(nil)
// TestProposalParameterChange(nil)
// TestProposalTally(nil)
}

func TestSubmitProposal() {
gov.Init()

id := gov.SubmitProposalText(
"title", // title
"summary", // summary
"metadata", // metadata
0, // initial deposit
)

now := uint64(time.Now().Unix())

if id != 1 {
panic("proposal id should be 1")
}

proposal := gov.GetProposalById(id)

if proposal.Title != "title" {
panic("proposal title should be title")
}

if proposal.Summary != "summary" {
panic("proposal summary should be summary")
}

if proposal.Metadata != "metadata" {
panic("proposal metadata should be metadata")
}

if proposal.ProposalStatus != gov.ProposalStatusDepositPeriod {
panic("proposal status should be deposit period")
}

if proposal.SubmitTime != now {
panic("proposal submit time should be now")
}

// 86400 == getDepositPeriod()
if proposal.DepositEndTime != now+86400 {
panic(fmt.Sprintf("proposal deposit end time should be now + deposit period, %d, %d", proposal.DepositEndTime, now+86400))
}

if proposal.VotingEndTime != 0 {
panic("proposal voting end time should be 0")
}

if proposal.TotalDeposit != 0 {
panic("proposal total deposits should be 0")
}

// 10_000_000 == getDepositMinimum()
// force advance to voting period
proposal.TotalDeposit = 10_000_000 + 1

/*
CAN NOT `process` in the integration filetest

// 86400 == getDepositPeriod()
if proposal.process(now + 86400 + 1) {
panic("proposal process should not halt")
}

// force advance to voting passed
proposal.YesVotes = 100
proposal.NoVotes = 0

// 259200 == getVotePeriod()
if proposal.process(now + 86400 + 1 + 259200 + 1) {
panic("proposal process should not halt")
}
*/
}

// OUTPUT:
//
4 changes: 4 additions & 0 deletions gov/api.gno
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ func GetActiveProposals() []Proposal {
return nil
}

func GetProposalById(proposalID uint64) *Proposal {
return &proposalsMap[proposalID]
}

func SubmitProposalText(
title string,
summary string,
Expand Down
1 change: 1 addition & 0 deletions gov/proposal_community_pool_spend.gno
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func (p ProposalCommunityPoolSpend) isValid() bool {
return false
}

return true
}

func (p ProposalCommunityPoolSpend) execute() error {
Expand Down
3 changes: 2 additions & 1 deletion pool/_RPC_dry.gno
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,8 @@ func DrySwap(
amount1 = i256.Zero().Sub(amountSpecified, state.amountSpecifiedRemaining)
}

pool.slot0.unlocked = true

if zeroForOne {
if pool.balances.token1.Lt(amount1.Abs()) {
// NOT ENOUGH BALANCE for output token1
Expand All @@ -199,6 +201,5 @@ func DrySwap(
return "0", "0", false
}

pool.slot0.unlocked = true
return amount0.ToString(), amount1.ToString(), true
}
25 changes: 0 additions & 25 deletions pool/_TEST_/_TEST_0_INIT_FAUCET_test.gno

This file was deleted.

178 changes: 0 additions & 178 deletions pool/_TEST_/_TEST_0_INIT_TOKEN_REGISTER_test.gno

This file was deleted.

Loading
Loading