Co-authored-by: Keefer Taylor | Tessellated <keefer@tessellated.io>
This commit is contained in:
co-authored by
Keefer Taylor | Tessellated
parent
43789945e9
commit
8b5ebc310a
@@ -116,9 +116,12 @@ func (s *IntegrationTestSuite) initNodes() {
|
||||
val0ConfigDir := s.chain.validators[0].configDir()
|
||||
|
||||
// Define the builder module parameters
|
||||
escrowAddress, err := sdk.AccAddressFromBech32("cosmos14j5j2lsx7629590jvpk3vj0xe9w8203jf4yknk")
|
||||
s.Require().Nil(err, "Unexpected error decoding escrow address")
|
||||
|
||||
params := types.Params{
|
||||
MaxBundleSize: 5,
|
||||
EscrowAccountAddress: "cosmos14j5j2lsx7629590jvpk3vj0xe9w8203jf4yknk",
|
||||
EscrowAccountAddress: escrowAddress,
|
||||
ReserveFee: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
MinBidIncrement: sdk.NewCoin(app.BondDenom, sdk.NewInt(1000000)),
|
||||
ProposerFee: sdk.NewDecWithPrec(1, 2),
|
||||
|
||||
+26
-26
@@ -49,7 +49,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
name: "Valid auction bid",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
@@ -76,14 +76,14 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Valid bid with multiple other transactions",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -132,14 +132,14 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "iterative bidding from the same account",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -191,14 +191,14 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid3)
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "bid with a bundle with transactions that are already in the mempool",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -251,14 +251,14 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "searcher attempts to include several txs in the same block to invalidate auction (we extract bid regardless)",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -310,7 +310,7 @@ func (s *IntegrationTestSuite) TestValidBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -359,7 +359,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
name: "broadcasting bids to two different validators (both should execute over several blocks) with same bid",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -417,14 +417,14 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance (both bids should have been extracted by this point)
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid).Add(s.calculateProposerEscrowSplit(bid2))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "multi-block auction bids with different bids",
|
||||
test: func() {
|
||||
// Get escrow account balance to ensure that it is updated correctly
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a multiple transaction that is valid
|
||||
bundle := make([][]byte, maxBundleSize)
|
||||
@@ -485,14 +485,14 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance (both bids should have been extracted by this point)
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid).Add(s.calculateProposerEscrowSplit(bid2))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance.Add(expectedEscrowFee), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Multiple bid transactions with second bid being smaller than min bid increment (same account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
@@ -527,7 +527,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait another block to make sure the second bid is not executed
|
||||
s.waitForABlock()
|
||||
@@ -538,7 +538,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
name: "Multiple transactions with second bid being smaller than min bid increment (different account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
@@ -573,7 +573,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait another block to make sure the second bid is not executed
|
||||
s.waitForABlock()
|
||||
@@ -584,7 +584,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
name: "Multiple transactions with increasing bids but first bid has same bundle so it should fail in later block (same account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
@@ -619,7 +619,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the first bid was not executed
|
||||
s.waitForABlock()
|
||||
@@ -630,7 +630,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
name: "Multiple transactions with increasing bids but first bid has same bundle so it should fail in later block (different account)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
bundle := [][]byte{
|
||||
@@ -665,7 +665,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the first bid was not executed
|
||||
s.waitForABlock()
|
||||
@@ -676,7 +676,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
name: "Multiple transactions with increasing bids and different bundles (one should execute)",
|
||||
test: func() {
|
||||
// Get escrow account balance
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Create a bundle with a single transaction
|
||||
firstBundle := [][]byte{
|
||||
@@ -717,7 +717,7 @@ func (s *IntegrationTestSuite) TestMultipleBids() {
|
||||
|
||||
// Ensure that the escrow account has the correct balance
|
||||
expectedEscrowFee := s.calculateProposerEscrowSplit(bid2)
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(expectedEscrowFee.Add(escrowBalance), s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
|
||||
// Wait for a block to be created and ensure that the second bid is executed
|
||||
s.waitForABlock()
|
||||
@@ -1004,14 +1004,14 @@ func (s *IntegrationTestSuite) TestInvalidBids() {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
escrowBalance := s.queryBalanceOf(escrowAddress, app.BondDenom)
|
||||
escrowBalance := s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom)
|
||||
|
||||
// Wait for a block to be created and run the test
|
||||
s.waitForABlock()
|
||||
s.Run(tc.name, tc.test)
|
||||
|
||||
// Get escrow account balance to ensure that it is not changed
|
||||
s.Require().Equal(escrowBalance, s.queryBalanceOf(escrowAddress, app.BondDenom))
|
||||
s.Require().Equal(escrowBalance, s.queryBalanceOf(sdk.AccAddress(escrowAddress).String(), app.BondDenom))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user