-
Notifications
You must be signed in to change notification settings - Fork 617
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
refactor/test(x/cosmwasmpool): tokenfactory shares and updated transmuter #5381
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d252f2c
new-transmuter
p0mvn 673b622
refactor/test(x/cosmwasmpool): tokenfactory shares and updated transm…
p0mvn d4ccb23
updates
p0mvn a3677cb
updates
p0mvn 6c28e5a
fix test
p0mvn 682738c
disable simulator
p0mvn 006ce98
update transmuter
p0mvn b2af802
correct share
p0mvn b0162b6
fix test AGAIN
p0mvn 55170c1
fix test
p0mvn 4754729
fix problem
p0mvn bc995e3
fix
p0mvn 0a6d0d0
update test
p0mvn 9b183be
updates
p0mvn 9cc6eb3
remove
p0mvn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
100 changes: 100 additions & 0 deletions
100
x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package transmuter_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/stretchr/testify/suite" | ||
|
||
"github.com/osmosis-labs/osmosis/v15/app/apptesting" | ||
incentivetypes "github.com/osmosis-labs/osmosis/v15/x/incentives/types" | ||
lockuptypes "github.com/osmosis-labs/osmosis/v15/x/lockup/types" | ||
tokenfactorytypes "github.com/osmosis-labs/osmosis/v15/x/tokenfactory/types" | ||
) | ||
|
||
const ( | ||
denomA = apptesting.DefaultTransmuterDenomA | ||
denomB = apptesting.DefaultTransmuterDenomB | ||
) | ||
|
||
// Suite for the transmuter contract. | ||
type TransmuterSuite struct { | ||
apptesting.KeeperTestHelper | ||
} | ||
|
||
var ( | ||
defaultPoolId = uint64(1) | ||
defaultAmount = sdk.NewInt(100) | ||
initalDefaultSupply = sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)) | ||
uosmo = "uosmo" | ||
|
||
defaultDenoms = []string{denomA, denomB} | ||
) | ||
|
||
func TestTransmuterSuite(t *testing.T) { | ||
suite.Run(t, new(TransmuterSuite)) | ||
} | ||
|
||
// This test functionally tests that the transmuter contract works as expected. | ||
// It validates: | ||
// - LP and tokenfactory share creation | ||
// - Ability to lock, create gauges for and incentivize such shares | ||
func (s *TransmuterSuite) TestFunctionalTransmuter() { | ||
s.Setup() | ||
|
||
const ( | ||
exppectedDenomPrefix = tokenfactorytypes.ModuleDenomPrefix + "/" | ||
expectedDenomSuffix = "/transmuter/poolshare" | ||
) | ||
|
||
// Create Transmuter pool | ||
transmuter := s.PrepareCosmWasmPool() | ||
|
||
contractAddress := transmuter.GetContractAddress() | ||
expectedShareDenom := exppectedDenomPrefix + contractAddress + expectedDenomSuffix | ||
|
||
// Validate that tokenfactory denom is created in the desired format. | ||
denomIteraror := s.App.TokenFactoryKeeper.GetAllDenomsIterator(s.Ctx) | ||
defer denomIteraror.Close() | ||
s.Require().True(denomIteraror.Valid()) | ||
s.Require().Equal(expectedShareDenom, string(denomIteraror.Value())) | ||
|
||
// Fund account | ||
s.FundAcc(s.TestAccs[0], initalDefaultSupply) | ||
|
||
// Join pool | ||
s.JoinTransmuterPool(s.TestAccs[0], defaultPoolId, initalDefaultSupply) | ||
|
||
// Check that the number of shares equals to the sum of the initial token amounts. | ||
shareCoin := s.App.BankKeeper.GetBalance(s.Ctx, s.TestAccs[0], expectedShareDenom) | ||
s.Require().Equal(defaultAmount.MulRaw(2), shareCoin.Amount) | ||
|
||
// Attempt to incentivize the tokenfactory shares | ||
|
||
// Lock shares | ||
shareCoins := sdk.NewCoins(shareCoin) | ||
lockDuration := time.Hour | ||
_, err := s.App.LockupKeeper.CreateLock(s.Ctx, s.TestAccs[0], shareCoins, lockDuration) | ||
s.Require().NoError(err) | ||
|
||
// Create gauge | ||
incentive := sdk.NewCoins(sdk.NewCoin(uosmo, sdk.NewInt(1_000_000))) | ||
s.FundAcc(s.TestAccs[1], incentive) | ||
gaugeId, err := s.App.IncentivesKeeper.CreateGauge(s.Ctx, true, s.TestAccs[1], incentive, lockuptypes.QueryCondition{ | ||
LockQueryType: lockuptypes.ByDuration, | ||
Denom: expectedShareDenom, | ||
Duration: lockDuration, | ||
}, s.Ctx.BlockTime(), 1) | ||
s.Require().NoError(err) | ||
gauge, err := s.App.IncentivesKeeper.GetGaugeByID(s.Ctx, gaugeId) | ||
s.Require().NoError(err) | ||
|
||
// Distirbute rewards | ||
coins, err := s.App.IncentivesKeeper.Distribute(s.Ctx, []incentivetypes.Gauge{*gauge}) | ||
s.Require().NoError(err) | ||
|
||
// Confirm that the rewards are distributed with no errors. | ||
s.Require().Equal(incentive.String(), coins.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See discussion for context: https://osmosis-network.slack.com/archives/C04LZFBHGQ5/p1685588880275719?thread_ts=1685506174.651869&cid=C04LZFBHGQ5
Also, see this: #4983