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(x/photon): migration #50

Closed
Closed
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
8b65111
exp: draft oh the photon module
tbruyelle Oct 1, 2024
9bce90f
burn msg
tbruyelle Oct 1, 2024
4584002
wip: MsgBurn implementation
tbruyelle Oct 2, 2024
d23aeb9
apply conversion
tbruyelle Oct 10, 2024
bfe0b5c
separate method for conversion rate
tbruyelle Oct 10, 2024
78dc06b
query conversion rate
tbruyelle Oct 10, 2024
bdae728
photon cli conversion-rate
tbruyelle Oct 10, 2024
f81fb27
photon tx cli burn
tbruyelle Oct 10, 2024
604e3df
rename file
tbruyelle Oct 10, 2024
2d0d772
remove x/params usage
tbruyelle Oct 10, 2024
86228e8
photon MsgUpdateParams
tbruyelle Oct 10, 2024
8b6ef34
setup tests with mocks
tbruyelle Oct 10, 2024
249b7bb
chore: add mockgen in devdeps
tbruyelle Oct 28, 2024
d142c79
test: add TestMsgServerUpdateParams
tbruyelle Oct 28, 2024
d0cb9b0
test: TestMsgServerBurn
tbruyelle Oct 28, 2024
8a6e583
TODO addressed
tbruyelle Oct 28, 2024
426dd55
fix photon max supply
tbruyelle Oct 28, 2024
63ad065
add TODO
tbruyelle Oct 28, 2024
be00193
chore: rename MsgBurn to MsgMintPhoton
tbruyelle Oct 29, 2024
0bd5deb
test: photon simulation
tbruyelle Oct 29, 2024
dfc1e03
fix lint
tbruyelle Nov 7, 2024
2de5cc2
feat(photon): add events for MintPhoton tx
tbruyelle Nov 7, 2024
b2e06d7
chore: improve start-localnet-ci target
tbruyelle Nov 7, 2024
148abcc
fix(photon): cli mint command
tbruyelle Nov 7, 2024
434edf6
test: add e2e test for minting photons
tbruyelle Nov 7, 2024
69532da
test: ConversionRate query
tbruyelle Nov 8, 2024
189ee74
add types.Denom const
tbruyelle Nov 8, 2024
9e328bd
move max supply into types pkg
tbruyelle Nov 8, 2024
3f2493b
test(e2e): photon param change proposal
tbruyelle Nov 8, 2024
22a813e
never return negative convert rate
tbruyelle Nov 8, 2024
aa16949
wip: photon fee decorator
tbruyelle Nov 14, 2024
69c34f6
test AnteDecorator
tbruyelle Nov 15, 2024
20de40d
improve spelling
tbruyelle Nov 18, 2024
445fb5a
dont validate fees for gentxs
tbruyelle Nov 18, 2024
cf46e18
fix and improve tests
tbruyelle Nov 18, 2024
b5f7adc
e2e tests working + uatone const
tbruyelle Nov 19, 2024
8d2e7a2
tests(e2e): address TODOs
tbruyelle Nov 20, 2024
fd3e9f5
feat(photon): ante handler allows 0 fee
tbruyelle Nov 20, 2024
1e48c2c
remove confusing NOTE
tbruyelle Nov 20, 2024
003910f
refac: allow any other fee if tx is excepted
tbruyelle Nov 21, 2024
fcb9b0d
introduce txFeeExceptions wildcard
tbruyelle Nov 21, 2024
41110e1
docs: improve comments
tbruyelle Nov 21, 2024
b1a3a1e
remove unused error definition
tbruyelle Nov 21, 2024
d3232b3
clarify comment
tbruyelle Nov 21, 2024
a8235b9
feat(photon): store upgrade
tbruyelle Nov 22, 2024
332c5fb
fix lint
tbruyelle Nov 25, 2024
9bc9c20
correct comment
tbruyelle Nov 25, 2024
1462248
add FIXME
tbruyelle Nov 25, 2024
43d931a
FIXME handled at 8e1732
tbruyelle Nov 25, 2024
40fe12a
fix(x/photon): handle when minted uphoton=0
tbruyelle Nov 25, 2024
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
Prev Previous commit
Next Next commit
test(e2e): photon param change proposal
tbruyelle committed Nov 8, 2024
commit 3f2493b46f6005ea552f2d0b022345314a0f1635
59 changes: 59 additions & 0 deletions tests/e2e/e2e_gov_test.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (
govtypes "github.com/atomone-hub/atomone/x/gov/types"
govtypesv1 "github.com/atomone-hub/atomone/x/gov/types/v1"
govtypesv1beta1 "github.com/atomone-hub/atomone/x/gov/types/v1beta1"
photontypes "github.com/atomone-hub/atomone/x/photon/types"
)

/*
@@ -177,6 +178,40 @@ func (s *IntegrationTestSuite) testGovParamChange() {
newParams := s.queryStakingParams(chainAAPIEndpoint)
s.Assert().NotEqual(oldMaxValidator, newParams.Params.MaxValidators)
})

s.Run("photon param change", func() {
// check existing params
chainAAPIEndpoint := fmt.Sprintf("http://%s", s.valResources[s.chainA.id][0].GetHostPort("1317/tcp"))
senderAddress, _ := s.chainA.validators[0].keyInfo.GetAddress()
sender := senderAddress.String()
params := s.queryPhotonParams(chainAAPIEndpoint)
// toggle param mint_disabled
oldMintDisabled := params.Params.MintDisabled
s.Require().False(oldMintDisabled, "expected photon param mint disabled to be false")
params.Params.MintDisabled = true

s.writePhotonParamChangeProposal(s.chainA, params.Params)
// Gov tests may be run in arbitrary order, each test must increment proposalCounter to have the correct proposal id to submit and query
proposalCounter++
submitGovFlags := []string{configFile(proposalParamChangeFilename)}
depositGovFlags := []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags := []string{strconv.Itoa(proposalCounter), "yes"}
s.submitGovProposal(chainAAPIEndpoint, sender, proposalCounter, "atomone.photon.v1.MsgUpdateParams", submitGovFlags, depositGovFlags, voteGovFlags, "vote")

newParams := s.queryPhotonParams(chainAAPIEndpoint)
s.Assert().True(newParams.Params.MintDisabled, "expected photon param mint disabled to be true")

// Revert change or mint photon test will fail
params.Params.MintDisabled = false
proposalCounter++
depositGovFlags = []string{strconv.Itoa(proposalCounter), depositAmount.String()}
voteGovFlags = []string{strconv.Itoa(proposalCounter), "yes"}
s.writePhotonParamChangeProposal(s.chainA, params.Params)
s.submitGovProposal(chainAAPIEndpoint, sender, proposalCounter, "atomone.photon.v1.MsgUpdateParams", submitGovFlags, depositGovFlags, voteGovFlags, "vote")

newParams = s.queryPhotonParams(chainAAPIEndpoint)
s.Require().False(newParams.Params.MintDisabled, "expected photon param mint disabled to be false")
})
}

func (s *IntegrationTestSuite) testGovConstitutionAmendment() {
@@ -315,6 +350,30 @@ func (s *IntegrationTestSuite) writeStakingParamChangeProposal(c *chain, params
s.Require().NoError(err)
}

func (s *IntegrationTestSuite) writePhotonParamChangeProposal(c *chain, params photontypes.Params) {
govModuleAddress := authtypes.NewModuleAddress(govtypes.ModuleName).String()

template := `
{
"messages":[
{
"@type": "/atomone.photon.v1.MsgUpdateParams",
"authority": "%s",
"params": %s
}
],
"deposit": "%s",
"proposer": "Proposing photon param change",
"metadata": "",
"title": "Change in photon params",
"summary": "summary"
}
`
propMsgBody := fmt.Sprintf(template, govModuleAddress, cdc.MustMarshalJSON(&params), initialDepositAmount)
err := writeFile(filepath.Join(c.validators[0].configDir(), "config", proposalParamChangeFilename), []byte(propMsgBody))
s.Require().NoError(err)
}

func (s *IntegrationTestSuite) writeGovConstitutionAmendmentProposal(c *chain, amendment string) {
govModuleAddress := authtypes.NewModuleAddress(govtypes.ModuleName).String()
// escape newlines in amendment
19 changes: 14 additions & 5 deletions tests/e2e/query_test.go
Original file line number Diff line number Diff line change
@@ -66,6 +66,15 @@ func queryAtomOneAllBalances(endpoint, addr string) (sdk.Coins, error) {
return balancesResp.Balances, nil
}

func (s *IntegrationTestSuite) queryBankSupply(endpoint string) sdk.Coins {
body, err := httpGet(fmt.Sprintf("%s/cosmos/bank/v1beta1/supply", endpoint))
s.Require().NoError(err)
var resp banktypes.QueryTotalSupplyResponse
err = cdc.UnmarshalJSON(body, &resp)
s.Require().NoError(err)
return resp.Supply
}

func queryStakingParams(endpoint string) (stakingtypes.QueryParamsResponse, error) { //nolint:unused
body, err := httpGet(fmt.Sprintf("%s/cosmos/staking/v1beta1/params", endpoint))
if err != nil {
@@ -289,11 +298,11 @@ func (s *IntegrationTestSuite) queryPhotonConversionRate(endpoint string) sdk.De
return sdk.MustNewDecFromStr(resp.ConversionRate)
}

func (s *IntegrationTestSuite) queryBankSupply(endpoint string) sdk.Coins {
body, err := httpGet(fmt.Sprintf("%s/cosmos/bank/v1beta1/supply", endpoint))
func (s *IntegrationTestSuite) queryPhotonParams(endpoint string) photontypes.QueryParamsResponse {
body, err := httpGet(fmt.Sprintf("%s/atomone/photon/v1/params", endpoint))
s.Require().NoError(err)
var resp banktypes.QueryTotalSupplyResponse
err = cdc.UnmarshalJSON(body, &resp)
var res photontypes.QueryParamsResponse
err = cdc.UnmarshalJSON(body, &res)
s.Require().NoError(err)
return resp.Supply
return res
}