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

init refactor testapp #330

Merged
merged 13 commits into from
May 2, 2024
Merged
12 changes: 6 additions & 6 deletions benchmark/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import (
"testing"

abci "github.com/cometbft/cometbft/abci/types"
"github.com/cometbft/cometbft/libs/log"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
"github.com/cosmos/cosmos-sdk/client"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/require"

testapp "github.com/bandprotocol/chain/v2/testing/testapp"
bandtesting "github.com/bandprotocol/chain/v2/testing"
"github.com/bandprotocol/chain/v2/x/oracle/keeper"
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
)

type BenchmarkApp struct {
*testapp.TestingApp
*bandtesting.TestingApp
Sender *Account
Validator *Account
Oid uint64
Expand All @@ -29,15 +28,16 @@ type BenchmarkApp struct {
}

func InitializeBenchmarkApp(tb testing.TB, maxGasPerBlock int64) *BenchmarkApp {
app, _ := bandtesting.CreateTestApp(&testing.T{}, false)
ba := &BenchmarkApp{
TestingApp: testapp.NewTestApp("", log.NewNopLogger()),
TestingApp: app,
Sender: &Account{
Account: testapp.Owner,
Account: bandtesting.Owner,
Num: 0,
Seq: 0,
},
Validator: &Account{
Account: testapp.Validators[0],
Account: bandtesting.Validators[0],
Num: 5,
Seq: 0,
},
Expand Down
6 changes: 3 additions & 3 deletions benchmark/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import (
"github.com/stretchr/testify/require"

"github.com/bandprotocol/chain/v2/pkg/obi"
"github.com/bandprotocol/chain/v2/testing/testapp"
bandtesting "github.com/bandprotocol/chain/v2/testing"
oracletypes "github.com/bandprotocol/chain/v2/x/oracle/types"
)

type Account struct {
testapp.Account
bandtesting.Account
Num uint64
Seq uint64
}
Expand Down Expand Up @@ -128,7 +128,7 @@ func GenSequenceOfTxs(
txs := make([]sdk.Tx, numTxs)

for i := 0; i < numTxs; i++ {
txs[i], _ = testapp.GenTx(
txs[i], _ = bandtesting.GenTx(
txConfig,
msgs,
sdk.Coins{sdk.NewInt64Coin("uband", 1)},
Expand Down
28 changes: 14 additions & 14 deletions testing/chain.go → testing/ibctesting/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"github.com/stretchr/testify/require"

bandapp "github.com/bandprotocol/chain/v2/app"
"github.com/bandprotocol/chain/v2/testing/testapp"
bandtesting "github.com/bandprotocol/chain/v2/testing"
"github.com/bandprotocol/chain/v2/x/oracle/types"
)

Expand All @@ -48,7 +48,7 @@ type TestChain struct {
t *testing.T

Coordinator *Coordinator
App *testapp.TestingApp
App *bandtesting.TestingApp
ChainID string
LastHeader *ibctmtypes.Header // header for last block height committed
CurrentHeader tmproto.Header // header for current block height
Expand Down Expand Up @@ -83,22 +83,22 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *TestChain {

for i := uint64(0); i < valSize; i++ {
// generate validator private/public key
privVal := mock.PV{PrivKey: testapp.Validators[i].PrivKey}
tmPub, err := cryptocodec.ToTmPubKeyInterface(testapp.Validators[i].PubKey)
privVal := mock.PV{PrivKey: bandtesting.Validators[i].PrivKey}
tmPub, err := cryptocodec.ToTmPubKeyInterface(bandtesting.Validators[i].PubKey)
require.NoError(t, err)

// create validator set with two validators
validators[i] = tmtypes.NewValidator(tmPub, 1)

signers[i] = privVal

senders[testapp.Validators[i].Address.String()] = authtypes.NewBaseAccount(
testapp.Validators[i].PubKey.Address().Bytes(),
testapp.Validators[i].PubKey,
senders[bandtesting.Validators[i].Address.String()] = authtypes.NewBaseAccount(
bandtesting.Validators[i].PubKey.Address().Bytes(),
bandtesting.Validators[i].PubKey,
i,
0,
)
genesisAccount[i] = senders[testapp.Validators[i].Address.String()]
genesisAccount[i] = senders[bandtesting.Validators[i].Address.String()]
balances[i] = banktypes.Balance{
Address: genesisAccount[i].GetAddress().String(),
Coins: sdk.NewCoins(sdk.NewCoin("uband", sdk.NewInt(10000000))),
Expand All @@ -107,7 +107,7 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *TestChain {

valSet := tmtypes.NewValidatorSet(validators)

app := testapp.SetupWithGenesisValSet(t, valSet, genesisAccount, chainID, balances...)
app := bandtesting.SetupWithGenesisValSet(t, valSet, genesisAccount, chainID, balances...)
ctx := app.NewContext(false, tmproto.Header{Height: app.LastBlockHeight()})
vals := app.StakingKeeper.GetAllValidators(ctx)
for _, v := range vals {
Expand Down Expand Up @@ -136,9 +136,9 @@ func NewTestChain(t *testing.T, coord *Coordinator, chainID string) *TestChain {
Codec: app.AppCodec(),
Vals: valSet,
Signers: signers,
SenderPrivKey: testapp.Validators[0].PrivKey,
SenderPrivKey: bandtesting.Validators[0].PrivKey,
SenderAccount: genesisAccount[0],
Treasury: testapp.Treasury.Address,
Treasury: bandtesting.Treasury.Address,
senders: senders,
}

Expand Down Expand Up @@ -254,7 +254,7 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) {
// ensure the chain has the latest time
chain.Coordinator.UpdateTimeForChain(chain)

_, r, err := testapp.SignAndDeliver(
_, r, err := bandtesting.SignAndDeliver(
chain.t,
chain.TxConfig,
chain.App.GetBaseApp(),
Expand Down Expand Up @@ -287,14 +287,14 @@ func (chain *TestChain) SendMsgs(msgs ...sdk.Msg) (*sdk.Result, error) {
func (chain *TestChain) SendReport(
rid types.RequestID,
rawReps []types.RawReport,
sender testapp.Account,
sender bandtesting.Account,
) (*sdk.Result, error) {
senderAccount := chain.senders[sender.Address.String()]

// ensure the chain has the latest time
chain.Coordinator.UpdateTimeForChain(chain)

_, r, err := testapp.SignAndDeliver(
_, r, err := bandtesting.SignAndDeliver(
chain.t,
chain.TxConfig,
chain.App.GetBaseApp(),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading
Loading