mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 10:05:18 +00:00
Compare commits
2 Commits
568ff70ad7
...
c18ca45188
Author | SHA1 | Date | |
---|---|---|---|
|
c18ca45188 | ||
|
f50d847c4f |
@ -48,9 +48,6 @@ func (suite *tallyHandlerSuite) SetupTest() {
|
|||||||
suite.tallier = NewTallyHandler(
|
suite.tallier = NewTallyHandler(
|
||||||
suite.app.GetGovKeeper(),
|
suite.app.GetGovKeeper(),
|
||||||
stakingKeeper,
|
stakingKeeper,
|
||||||
suite.app.GetSavingsKeeper(),
|
|
||||||
suite.app.GetEarnKeeper(),
|
|
||||||
suite.app.GetLiquidKeeper(),
|
|
||||||
suite.app.GetBankKeeper(),
|
suite.app.GetBankKeeper(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ import (
|
|||||||
"github.com/0glabs/0g-chain/client/grpc/util"
|
"github.com/0glabs/0g-chain/client/grpc/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// KavaGrpcClient enables the usage of kava grpc query clients and query utils
|
// ZgChainGrpcClient enables the usage of kava grpc query clients and query utils
|
||||||
type KavaGrpcClient struct {
|
type ZgChainGrpcClient struct {
|
||||||
config KavaGrpcClientConfig
|
config ZgChainGrpcClientConfig
|
||||||
|
|
||||||
// Query clients for cosmos and kava modules
|
// Query clients for cosmos and kava modules
|
||||||
Query *query.QueryClient
|
Query *query.QueryClient
|
||||||
@ -18,18 +18,18 @@ type KavaGrpcClient struct {
|
|||||||
*util.Util
|
*util.Util
|
||||||
}
|
}
|
||||||
|
|
||||||
// KavaGrpcClientConfig is a configuration struct for a KavaGrpcClient
|
// ZgChainGrpcClientConfig is a configuration struct for a ZgChainGrpcClient
|
||||||
type KavaGrpcClientConfig struct {
|
type ZgChainGrpcClientConfig struct {
|
||||||
// note: add future config options here
|
// note: add future config options here
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a new KavaGrpcClient via a grpc url
|
// NewClient creates a new ZgChainGrpcClient via a grpc url
|
||||||
func NewClient(grpcUrl string) (*KavaGrpcClient, error) {
|
func NewClient(grpcUrl string) (*ZgChainGrpcClient, error) {
|
||||||
return NewClientWithConfig(grpcUrl, NewDefaultConfig())
|
return NewClientWithConfig(grpcUrl, NewDefaultConfig())
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientWithConfig creates a new KavaGrpcClient via a grpc url and config
|
// NewClientWithConfig creates a new ZgChainGrpcClient via a grpc url and config
|
||||||
func NewClientWithConfig(grpcUrl string, config KavaGrpcClientConfig) (*KavaGrpcClient, error) {
|
func NewClientWithConfig(grpcUrl string, config ZgChainGrpcClientConfig) (*ZgChainGrpcClient, error) {
|
||||||
if grpcUrl == "" {
|
if grpcUrl == "" {
|
||||||
return nil, errors.New("grpc url cannot be empty")
|
return nil, errors.New("grpc url cannot be empty")
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ func NewClientWithConfig(grpcUrl string, config KavaGrpcClientConfig) (*KavaGrpc
|
|||||||
if error != nil {
|
if error != nil {
|
||||||
return nil, error
|
return nil, error
|
||||||
}
|
}
|
||||||
client := &KavaGrpcClient{
|
client := &ZgChainGrpcClient{
|
||||||
Query: query,
|
Query: query,
|
||||||
Util: util.NewUtil(query),
|
Util: util.NewUtil(query),
|
||||||
config: config,
|
config: config,
|
||||||
@ -45,6 +45,6 @@ func NewClientWithConfig(grpcUrl string, config KavaGrpcClientConfig) (*KavaGrpc
|
|||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDefaultConfig() KavaGrpcClientConfig {
|
func NewDefaultConfig() ZgChainGrpcClientConfig {
|
||||||
return KavaGrpcClientConfig{}
|
return ZgChainGrpcClientConfig{}
|
||||||
}
|
}
|
||||||
|
@ -60,21 +60,11 @@ type QueryClient struct {
|
|||||||
|
|
||||||
// kava module query clients
|
// kava module query clients
|
||||||
|
|
||||||
Auction auctiontypes.QueryClient
|
|
||||||
Bep3 bep3types.QueryClient
|
Bep3 bep3types.QueryClient
|
||||||
Cdp cdptypes.QueryClient
|
|
||||||
Committee committeetypes.QueryClient
|
Committee committeetypes.QueryClient
|
||||||
Community communitytypes.QueryClient
|
|
||||||
Earn earntypes.QueryClient
|
|
||||||
Evmutil evmutiltypes.QueryClient
|
Evmutil evmutiltypes.QueryClient
|
||||||
Hard hardtypes.QueryClient
|
|
||||||
Incentive incentivetypes.QueryClient
|
|
||||||
Issuance issuancetypes.QueryClient
|
Issuance issuancetypes.QueryClient
|
||||||
Kavadist kavadisttypes.QueryClient
|
|
||||||
Liquid liquidtypes.QueryClient
|
|
||||||
Pricefeed pricefeedtypes.QueryClient
|
Pricefeed pricefeedtypes.QueryClient
|
||||||
Savings savingstypes.QueryClient
|
|
||||||
Swap swaptypes.QueryClient
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewQueryClient creates a new QueryClient and initializes all the module query clients
|
// NewQueryClient creates a new QueryClient and initializes all the module query clients
|
||||||
@ -105,21 +95,11 @@ func NewQueryClient(grpcEndpoint string) (*QueryClient, error) {
|
|||||||
IbcClient: ibcclienttypes.NewQueryClient(conn),
|
IbcClient: ibcclienttypes.NewQueryClient(conn),
|
||||||
IbcTransfer: ibctransfertypes.NewQueryClient(conn),
|
IbcTransfer: ibctransfertypes.NewQueryClient(conn),
|
||||||
|
|
||||||
Auction: auctiontypes.NewQueryClient(conn),
|
|
||||||
Bep3: bep3types.NewQueryClient(conn),
|
Bep3: bep3types.NewQueryClient(conn),
|
||||||
Cdp: cdptypes.NewQueryClient(conn),
|
|
||||||
Committee: committeetypes.NewQueryClient(conn),
|
Committee: committeetypes.NewQueryClient(conn),
|
||||||
Community: communitytypes.NewQueryClient(conn),
|
|
||||||
Earn: earntypes.NewQueryClient(conn),
|
|
||||||
Evmutil: evmutiltypes.NewQueryClient(conn),
|
Evmutil: evmutiltypes.NewQueryClient(conn),
|
||||||
Hard: hardtypes.NewQueryClient(conn),
|
|
||||||
Incentive: incentivetypes.NewQueryClient(conn),
|
|
||||||
Issuance: issuancetypes.NewQueryClient(conn),
|
Issuance: issuancetypes.NewQueryClient(conn),
|
||||||
Kavadist: kavadisttypes.NewQueryClient(conn),
|
|
||||||
Liquid: liquidtypes.NewQueryClient(conn),
|
|
||||||
Pricefeed: pricefeedtypes.NewQueryClient(conn),
|
Pricefeed: pricefeedtypes.NewQueryClient(conn),
|
||||||
Savings: savingstypes.NewQueryClient(conn),
|
|
||||||
Swap: swaptypes.NewQueryClient(conn),
|
|
||||||
}
|
}
|
||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
@ -55,20 +55,10 @@ func TestNewQueryClient_ValidClient(t *testing.T) {
|
|||||||
require.NotNil(t, client.IbcTransfer)
|
require.NotNil(t, client.IbcTransfer)
|
||||||
|
|
||||||
// validate kava clients
|
// validate kava clients
|
||||||
require.NotNil(t, client.Auction)
|
|
||||||
require.NotNil(t, client.Bep3)
|
require.NotNil(t, client.Bep3)
|
||||||
require.NotNil(t, client.Cdp)
|
|
||||||
require.NotNil(t, client.Committee)
|
require.NotNil(t, client.Committee)
|
||||||
require.NotNil(t, client.Community)
|
|
||||||
require.NotNil(t, client.Earn)
|
|
||||||
require.NotNil(t, client.Evmutil)
|
require.NotNil(t, client.Evmutil)
|
||||||
require.NotNil(t, client.Hard)
|
|
||||||
require.NotNil(t, client.Incentive)
|
|
||||||
require.NotNil(t, client.Issuance)
|
require.NotNil(t, client.Issuance)
|
||||||
require.NotNil(t, client.Kavadist)
|
|
||||||
require.NotNil(t, client.Liquid)
|
|
||||||
require.NotNil(t, client.Pricefeed)
|
require.NotNil(t, client.Pricefeed)
|
||||||
require.NotNil(t, client.Savings)
|
|
||||||
require.NotNil(t, client.Swap)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
simappparams "cosmossdk.io/simapp/params"
|
||||||
"github.com/0glabs/0g-chain/client/rest"
|
"github.com/0glabs/0g-chain/client/rest"
|
||||||
"github.com/cosmos/cosmos-sdk/client"
|
"github.com/cosmos/cosmos-sdk/client"
|
||||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||||
|
2
go.mod
2
go.mod
@ -5,6 +5,7 @@ go 1.21
|
|||||||
require (
|
require (
|
||||||
cosmossdk.io/errors v1.0.1
|
cosmossdk.io/errors v1.0.1
|
||||||
cosmossdk.io/math v1.3.0
|
cosmossdk.io/math v1.3.0
|
||||||
|
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015
|
||||||
github.com/cenkalti/backoff/v4 v4.1.3
|
github.com/cenkalti/backoff/v4 v4.1.3
|
||||||
github.com/cometbft/cometbft v0.37.4
|
github.com/cometbft/cometbft v0.37.4
|
||||||
github.com/cometbft/cometbft-db v0.9.1
|
github.com/cometbft/cometbft-db v0.9.1
|
||||||
@ -52,7 +53,6 @@ require (
|
|||||||
cosmossdk.io/core v0.6.1 // indirect
|
cosmossdk.io/core v0.6.1 // indirect
|
||||||
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
|
cosmossdk.io/depinject v1.0.0-alpha.4 // indirect
|
||||||
cosmossdk.io/log v1.3.1 // indirect
|
cosmossdk.io/log v1.3.1 // indirect
|
||||||
cosmossdk.io/simapp v0.0.0-20231127212628-044ff4d8c015 // indirect
|
|
||||||
cosmossdk.io/tools/rosetta v0.2.1 // indirect
|
cosmossdk.io/tools/rosetta v0.2.1 // indirect
|
||||||
filippo.io/edwards25519 v1.0.0 // indirect
|
filippo.io/edwards25519 v1.0.0 // indirect
|
||||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
// communitytypes "github.com/0glabs/0g-chain/x/community/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// func (suite *IntegrationTestSuite) TestCommunityUpdateParams_NonAuthority() {
|
// func (suite *IntegrationTestSuite) TestCommunityUpdateParams_NonAuthority() {
|
||||||
|
@ -25,7 +25,10 @@ func setupConvertToCoinTest(
|
|||||||
) (denom string, initialFunds sdk.Coins, user *testutil.SigningAccount) {
|
) (denom string, initialFunds sdk.Coins, user *testutil.SigningAccount) {
|
||||||
// we expect a denom to be registered to the allowed denoms param
|
// we expect a denom to be registered to the allowed denoms param
|
||||||
// and for the funded account to have a balance for that denom
|
// and for the funded account to have a balance for that denom
|
||||||
params, err := suite.ZgChain.Evmutil.Params(context.Background(), &evmutiltypes.QueryParamsRequest{})
|
params, err := suite.ZgChain.Grpc.Query.Evmutil.Params(
|
||||||
|
context.Background(),
|
||||||
|
&evmutiltypes.QueryParamsRequest{},
|
||||||
|
)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.GreaterOrEqual(
|
suite.GreaterOrEqual(
|
||||||
len(params.Params.AllowedCosmosDenoms), 1,
|
len(params.Params.AllowedCosmosDenoms), 1,
|
||||||
@ -74,7 +77,7 @@ func (suite *IntegrationTestSuite) setupAccountWithCosmosCoinERC20Balance(
|
|||||||
sdkBalance = sdkBalance.Sub(convertAmount)
|
sdkBalance = sdkBalance.Sub(convertAmount)
|
||||||
|
|
||||||
// query for the deployed contract
|
// query for the deployed contract
|
||||||
deployedContracts, err := suite.ZgChain.Evmutil.DeployedCosmosCoinContracts(
|
deployedContracts, err := suite.ZgChain.Grpc.Query.Evmutil.DeployedCosmosCoinContracts(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
||||||
)
|
)
|
||||||
@ -110,7 +113,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
|
|||||||
suite.NoError(res.Err)
|
suite.NoError(res.Err)
|
||||||
|
|
||||||
// query for the deployed contract
|
// query for the deployed contract
|
||||||
deployedContracts, err := suite.ZgChain.Evmutil.DeployedCosmosCoinContracts(
|
deployedContracts, err := suite.ZgChain.Grpc.Query.Evmutil.DeployedCosmosCoinContracts(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
||||||
)
|
)
|
||||||
@ -192,18 +195,18 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
|||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// submit the eip712 message to the chain.
|
// submit the eip712 message to the chain.
|
||||||
res, err := suite.ZgChain.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
res, err := suite.ZgChain.Grpc.Query.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
||||||
TxBytes: txBytes,
|
TxBytes: txBytes,
|
||||||
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
||||||
})
|
})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
||||||
|
|
||||||
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 12*time.Second)
|
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Grpc.Query.Tx, res.TxResponse.TxHash, 12*time.Second)
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
|
||||||
// query for the deployed contract
|
// query for the deployed contract
|
||||||
deployedContracts, err := suite.ZgChain.Evmutil.DeployedCosmosCoinContracts(
|
deployedContracts, err := suite.ZgChain.Grpc.Query.Evmutil.DeployedCosmosCoinContracts(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
&evmutiltypes.QueryDeployedCosmosCoinContractsRequest{CosmosDenoms: []string{denom}},
|
||||||
)
|
)
|
||||||
@ -246,14 +249,14 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
|||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// submit the eip712 message to the chain
|
// submit the eip712 message to the chain
|
||||||
res, err = suite.ZgChain.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
res, err = suite.ZgChain.Grpc.Query.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
||||||
TxBytes: txBytes,
|
TxBytes: txBytes,
|
||||||
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
||||||
})
|
})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
||||||
|
|
||||||
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second)
|
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Grpc.Query.Tx, res.TxResponse.TxHash, 6*time.Second)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check erc20 balance
|
// check erc20 balance
|
||||||
|
@ -85,18 +85,18 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
|||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// broadcast tx
|
// broadcast tx
|
||||||
res, err := suite.ZgChain.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
res, err := suite.ZgChain.Grpc.Query.Tx.BroadcastTx(context.Background(), &txtypes.BroadcastTxRequest{
|
||||||
TxBytes: txBytes,
|
TxBytes: txBytes,
|
||||||
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
Mode: txtypes.BroadcastMode_BROADCAST_MODE_SYNC,
|
||||||
})
|
})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
suite.Equal(sdkerrors.SuccessABCICode, res.TxResponse.Code)
|
||||||
|
|
||||||
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second)
|
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Grpc.Query.Tx, res.TxResponse.TxHash, 6*time.Second)
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
// check that the message was processed & the gas denom is transferred.
|
// check that the message was processed & the gas denom is transferred.
|
||||||
balRes, err := suite.ZgChain.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
balRes, err := suite.ZgChain.Grpc.Query.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||||
Address: receiver.String(),
|
Address: receiver.String(),
|
||||||
Denom: chaincfg.GasDenom,
|
Denom: chaincfg.GasDenom,
|
||||||
})
|
})
|
||||||
|
@ -6,18 +6,19 @@ import (
|
|||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||||
|
|
||||||
|
"github.com/0glabs/0g-chain/chaincfg"
|
||||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() {
|
func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
// setup kava account
|
// setup 0g account
|
||||||
funds := ukava(1e5) // .1 KAVA
|
funds := chaincfg.MakeCoinForGasDenom(1e5)
|
||||||
kavaAcc := suite.Kava.NewFundedAccount("balance-test", sdk.NewCoins(funds))
|
zgAcc := suite.ZgChain.NewFundedAccount("balance-test", sdk.NewCoins(funds))
|
||||||
|
|
||||||
// ACT
|
// ACT
|
||||||
rsp, err := suite.Kava.Grpc.Query.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
rsp, err := suite.ZgChain.Grpc.Query.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||||
Address: kavaAcc.SdkAddress.String(),
|
Address: zgAcc.SdkAddress.String(),
|
||||||
Denom: funds.Denom,
|
Denom: funds.Denom,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -28,7 +29,7 @@ func (suite *IntegrationTestSuite) TestGrpcClientQueryCosmosModule_Balance() {
|
|||||||
|
|
||||||
func (suite *IntegrationTestSuite) TestGrpcClientQueryKavaModule_EvmParams() {
|
func (suite *IntegrationTestSuite) TestGrpcClientQueryKavaModule_EvmParams() {
|
||||||
// ACT
|
// ACT
|
||||||
rsp, err := suite.Kava.Grpc.Query.Evmutil.Params(
|
rsp, err := suite.ZgChain.Grpc.Query.Evmutil.Params(
|
||||||
context.Background(), &evmutiltypes.QueryParamsRequest{},
|
context.Background(), &evmutiltypes.QueryParamsRequest{},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,20 +1,21 @@
|
|||||||
package e2e_test
|
package e2e_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/0glabs/0g-chain/chaincfg"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (suite *IntegrationTestSuite) TestGrpcClientUtil_Account() {
|
func (suite *IntegrationTestSuite) TestGrpcClientUtil_Account() {
|
||||||
// ARRANGE
|
// ARRANGE
|
||||||
// setup kava account
|
// setup 0g account
|
||||||
kavaAcc := suite.Kava.NewFundedAccount("account-test", sdk.NewCoins(ukava(1e5)))
|
zgAcc := suite.ZgChain.NewFundedAccount("account-test", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e5)))
|
||||||
|
|
||||||
// ACT
|
// ACT
|
||||||
rsp, err := suite.Kava.Grpc.BaseAccount(kavaAcc.SdkAddress.String())
|
rsp, err := suite.ZgChain.Grpc.BaseAccount(zgAcc.SdkAddress.String())
|
||||||
|
|
||||||
// ASSERT
|
// ASSERT
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
suite.Equal(kavaAcc.SdkAddress.String(), rsp.Address)
|
suite.Equal(zgAcc.SdkAddress.String(), rsp.Address)
|
||||||
suite.Greater(rsp.AccountNumber, uint64(1))
|
suite.Greater(rsp.AccountNumber, uint64(1))
|
||||||
suite.Equal(uint64(0), rsp.Sequence)
|
suite.Equal(uint64(0), rsp.Sequence)
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func (suite *IntegrationTestSuite) TestChainID() {
|
|||||||
suite.Equal(expectedEvmNetworkId, evmNetworkId)
|
suite.Equal(expectedEvmNetworkId, evmNetworkId)
|
||||||
|
|
||||||
// SDK query
|
// SDK query
|
||||||
nodeInfo, err := suite.ZgChain.Tm.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
|
nodeInfo, err := suite.ZgChain.Grpc.Query.Tm.GetNodeInfo(context.Background(), &tmservice.GetNodeInfoRequest{})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(suite.ZgChain.ChainID, nodeInfo.DefaultNodeInfo.Network)
|
suite.Equal(suite.ZgChain.ChainID, nodeInfo.DefaultNodeInfo.Network)
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ func (suite *IntegrationTestSuite) TestFundedAccount() {
|
|||||||
suite.Equal(acc.EvmAddress.Hex(), util.SdkToEvmAddress(acc.SdkAddress).Hex())
|
suite.Equal(acc.EvmAddress.Hex(), util.SdkToEvmAddress(acc.SdkAddress).Hex())
|
||||||
|
|
||||||
// check balance via SDK query
|
// check balance via SDK query
|
||||||
res, err := suite.ZgChain.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest(
|
res, err := suite.ZgChain.Grpc.Query.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest(
|
||||||
acc.SdkAddress, chaincfg.GasDenom,
|
acc.SdkAddress, chaincfg.GasDenom,
|
||||||
))
|
))
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
@ -13,11 +13,11 @@ import (
|
|||||||
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
||||||
suite.SkipIfUpgradeDisabled()
|
suite.SkipIfUpgradeDisabled()
|
||||||
|
|
||||||
beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
beforeUpgradeCtx := suite.ZgChain.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
afterUpgradeCtx := suite.ZgChain.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||||
|
|
||||||
// Before params
|
// Before params
|
||||||
grpcClient := suite.Kava.Grpc
|
grpcClient := suite.ZgChain.Grpc
|
||||||
govParamsBefore, err := grpcClient.Query.Gov.Params(beforeUpgradeCtx, &govtypes.QueryParamsRequest{
|
govParamsBefore, err := grpcClient.Query.Gov.Params(beforeUpgradeCtx, &govtypes.QueryParamsRequest{
|
||||||
ParamsType: govtypes.ParamDeposit,
|
ParamsType: govtypes.ParamDeposit,
|
||||||
})
|
})
|
||||||
@ -47,13 +47,13 @@ func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
|||||||
"x/gov DepositParams max deposit period after upgrade should be 172800s",
|
"x/gov DepositParams max deposit period after upgrade should be 172800s",
|
||||||
)
|
)
|
||||||
suite.Assert().Equal(
|
suite.Assert().Equal(
|
||||||
[]sdk.Coin{{Denom: "ukava", Amount: sdk.NewInt(10_000_000)}},
|
[]sdk.Coin{{Denom: "ua0gi", Amount: sdk.NewInt(10_000_000)}},
|
||||||
govParamsAfter.DepositParams.MinDeposit,
|
govParamsAfter.DepositParams.MinDeposit,
|
||||||
"x/gov DepositParams min deposit after upgrade should be 10_000_000 ukava",
|
"x/gov DepositParams min deposit after upgrade should be 10_000_000 ukava",
|
||||||
)
|
)
|
||||||
|
|
||||||
expectedParams := govtypes.Params{
|
expectedParams := govtypes.Params{
|
||||||
MinDeposit: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(10_000_000))),
|
MinDeposit: sdk.NewCoins(sdk.NewCoin("ua0gi", sdk.NewInt(10_000_000))),
|
||||||
MaxDepositPeriod: mustParseDuration("172800s"),
|
MaxDepositPeriod: mustParseDuration("172800s"),
|
||||||
VotingPeriod: mustParseDuration("30s"),
|
VotingPeriod: mustParseDuration("30s"),
|
||||||
Quorum: "0.334000000000000000",
|
Quorum: "0.334000000000000000",
|
||||||
@ -71,9 +71,9 @@ func (suite *IntegrationTestSuite) TestUpgradeParams_SDK() {
|
|||||||
func (suite *IntegrationTestSuite) TestUpgradeParams_Consensus() {
|
func (suite *IntegrationTestSuite) TestUpgradeParams_Consensus() {
|
||||||
suite.SkipIfUpgradeDisabled()
|
suite.SkipIfUpgradeDisabled()
|
||||||
|
|
||||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
afterUpgradeCtx := suite.ZgChain.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||||
|
|
||||||
grpcClient := suite.Kava.Grpc
|
grpcClient := suite.ZgChain.Grpc
|
||||||
paramsAfter, err := grpcClient.Query.Consensus.Params(afterUpgradeCtx, &consensustypes.QueryParamsRequest{})
|
paramsAfter, err := grpcClient.Query.Consensus.Params(afterUpgradeCtx, &consensustypes.QueryParamsRequest{})
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
|
|
||||||
@ -98,25 +98,25 @@ func (suite *IntegrationTestSuite) TestUpgradeParams_Consensus() {
|
|||||||
suite.Require().Equal(expectedParams, *paramsAfter.Params, "x/consensus params after upgrade should be as expected")
|
suite.Require().Equal(expectedParams, *paramsAfter.Params, "x/consensus params after upgrade should be as expected")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (suite *IntegrationTestSuite) TestUpgradeParams_CDP_Interval() {
|
// func (suite *IntegrationTestSuite) TestUpgradeParams_CDP_Interval() {
|
||||||
suite.SkipIfUpgradeDisabled()
|
// suite.SkipIfUpgradeDisabled()
|
||||||
|
|
||||||
beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
// beforeUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight - 1)
|
||||||
afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
// afterUpgradeCtx := suite.Kava.Grpc.CtxAtHeight(suite.UpgradeHeight)
|
||||||
|
|
||||||
grpcClient := suite.Kava.Grpc
|
// grpcClient := suite.Kava.Grpc
|
||||||
|
|
||||||
paramsBefore, err := grpcClient.Query.Cdp.Params(beforeUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
// paramsBefore, err := grpcClient.Query.Cdp.Params(beforeUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||||
suite.Require().NoError(err)
|
// suite.Require().NoError(err)
|
||||||
paramsAfter, err := grpcClient.Query.Cdp.Params(afterUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
// paramsAfter, err := grpcClient.Query.Cdp.Params(afterUpgradeCtx, &cdptypes.QueryParamsRequest{})
|
||||||
suite.Require().NoError(err)
|
// suite.Require().NoError(err)
|
||||||
|
|
||||||
expectedParams := paramsBefore.Params
|
// expectedParams := paramsBefore.Params
|
||||||
expectedParams.LiquidationBlockInterval = int64(50)
|
// expectedParams.LiquidationBlockInterval = int64(50)
|
||||||
|
|
||||||
suite.Require().Equal(expectedParams, paramsAfter.Params,
|
// suite.Require().Equal(expectedParams, paramsAfter.Params,
|
||||||
"expected cdp parameters to equal previous parameters with a liquidation block interval of 100")
|
// "expected cdp parameters to equal previous parameters with a liquidation block interval of 100")
|
||||||
}
|
// }
|
||||||
|
|
||||||
func mustParseDuration(s string) *time.Duration {
|
func mustParseDuration(s string) *time.Duration {
|
||||||
d, err := time.ParseDuration(s)
|
d, err := time.ParseDuration(s)
|
||||||
|
@ -21,14 +21,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/ethclient"
|
"github.com/ethereum/go-ethereum/ethclient"
|
||||||
|
|
||||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
|
||||||
|
|
||||||
"github.com/0glabs/0g-chain/app"
|
"github.com/0glabs/0g-chain/app"
|
||||||
chainparams "github.com/0glabs/0g-chain/app/params"
|
chainparams "github.com/0glabs/0g-chain/app/params"
|
||||||
|
"github.com/0glabs/0g-chain/client/grpc"
|
||||||
"github.com/0glabs/0g-chain/tests/e2e/runner"
|
"github.com/0glabs/0g-chain/tests/e2e/runner"
|
||||||
"github.com/0glabs/0g-chain/tests/util"
|
"github.com/0glabs/0g-chain/tests/util"
|
||||||
committeetypes "github.com/0glabs/0g-chain/x/committee/types"
|
|
||||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Chain wraps query clients & accounts for a network
|
// Chain wraps query clients & accounts for a network
|
||||||
@ -46,23 +43,9 @@ type Chain struct {
|
|||||||
|
|
||||||
EncodingConfig chainparams.EncodingConfig
|
EncodingConfig chainparams.EncodingConfig
|
||||||
|
|
||||||
Auth authtypes.QueryClient
|
|
||||||
Authz authz.QueryClient
|
|
||||||
Bank banktypes.QueryClient
|
|
||||||
Committee committeetypes.QueryClient
|
|
||||||
Distribution distrtypes.QueryClient
|
|
||||||
Evm evmtypes.QueryClient
|
|
||||||
Evmutil evmutiltypes.QueryClient
|
|
||||||
Gov govv1types.QueryClient
|
|
||||||
Mint minttypes.QueryClient
|
|
||||||
Staking stakingtypes.QueryClient
|
|
||||||
Tm tmservice.ServiceClient
|
|
||||||
Tx txtypes.ServiceClient
|
|
||||||
Upgrade upgradetypes.QueryClient
|
|
||||||
|
|
||||||
TmSignClient tmclient.SignClient
|
TmSignClient tmclient.SignClient
|
||||||
|
|
||||||
Grpc *grpc.KavaGrpcClient
|
Grpc *grpc.ZgChainGrpcClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewChain creates the query clients & signing account management for a chain run on a set of ports.
|
// NewChain creates the query clients & signing account management for a chain run on a set of ports.
|
||||||
@ -94,7 +77,7 @@ func NewChain(t *testing.T, details *runner.ChainDetails, fundedAccountMnemonic
|
|||||||
|
|
||||||
client, err := grpc.NewClient(details.GrpcUrl)
|
client, err := grpc.NewClient(details.GrpcUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
chain.t.Fatalf("failed to create kava grpc client: %s", err)
|
chain.t.Fatalf("failed to create 0g-chain grpc client: %s", err)
|
||||||
}
|
}
|
||||||
chain.Grpc = client
|
chain.Grpc = client
|
||||||
|
|
||||||
@ -108,21 +91,6 @@ func NewChain(t *testing.T, details *runner.ChainDetails, fundedAccountMnemonic
|
|||||||
return chain, err
|
return chain, err
|
||||||
}
|
}
|
||||||
|
|
||||||
chain.Auth = authtypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Authz = authz.NewQueryClient(grpcConn)
|
|
||||||
chain.Bank = banktypes.NewQueryClient(grpcConn)
|
|
||||||
|
|
||||||
chain.Committee = committeetypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Distribution = distrtypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Evm = evmtypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Evmutil = evmutiltypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Gov = govv1types.NewQueryClient(grpcConn)
|
|
||||||
chain.Mint = minttypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Staking = stakingtypes.NewQueryClient(grpcConn)
|
|
||||||
chain.Tm = tmservice.NewServiceClient(grpcConn)
|
|
||||||
chain.Tx = txtypes.NewServiceClient(grpcConn)
|
|
||||||
chain.Upgrade = upgradetypes.NewQueryClient(grpcConn)
|
|
||||||
|
|
||||||
// initialize accounts map
|
// initialize accounts map
|
||||||
chain.accounts = make(map[string]*SigningAccount)
|
chain.accounts = make(map[string]*SigningAccount)
|
||||||
// setup the signing account for the initially funded account (used to fund all other accounts)
|
// setup the signing account for the initially funded account (used to fund all other accounts)
|
||||||
|
@ -27,7 +27,7 @@ func (suite *E2eTestSuite) InitZgChainEvmData() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// expect the erc20 to be enabled for conversion to sdk.Coin
|
// expect the erc20 to be enabled for conversion to sdk.Coin
|
||||||
params, err := suite.ZgChain.Evmutil.Params(context.Background(), &evmutiltypes.QueryParamsRequest{})
|
params, err := suite.ZgChain.Grpc.Query.Evmutil.Params(context.Background(), &evmutiltypes.QueryParamsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("failed to fetch evmutil params during init: %s", err))
|
panic(fmt.Sprintf("failed to fetch evmutil params during init: %s", err))
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,6 @@ import (
|
|||||||
"github.com/0glabs/0g-chain/x/evmutil/keeper"
|
"github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||||
"github.com/0glabs/0g-chain/x/evmutil/testutil"
|
"github.com/0glabs/0g-chain/x/evmutil/testutil"
|
||||||
"github.com/0glabs/0g-chain/x/evmutil/types"
|
"github.com/0glabs/0g-chain/x/evmutil/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
|
||||||
vesting "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
|
|
||||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
|
||||||
"github.com/stretchr/testify/suite"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type evmBankKeeperTestSuite struct {
|
type evmBankKeeperTestSuite struct {
|
||||||
|
@ -198,10 +198,10 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() {
|
|||||||
{
|
{
|
||||||
name: "invalid - invalid initiator address",
|
name: "invalid - invalid initiator address",
|
||||||
msg: types.MsgConvertERC20ToCoin{
|
msg: types.MsgConvertERC20ToCoin{
|
||||||
Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
Initiator: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||||
Receiver: invokerCosmosAddr.String(),
|
Receiver: invokerCosmosAddr.String(),
|
||||||
KavaERC20Address: contractAddr.String(),
|
ZgChainERC20Address: contractAddr.String(),
|
||||||
Amount: sdkmath.NewInt(12e8),
|
Amount: sdkmath.NewInt(12e8),
|
||||||
},
|
},
|
||||||
userErc20Balance: sdkmath.NewInt(2e18),
|
userErc20Balance: sdkmath.NewInt(2e18),
|
||||||
errArgs: errArgs{
|
errArgs: errArgs{
|
||||||
@ -214,7 +214,7 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() {
|
|||||||
msg: types.MsgConvertERC20ToCoin{
|
msg: types.MsgConvertERC20ToCoin{
|
||||||
Initiator: invoker.String(),
|
Initiator: invoker.String(),
|
||||||
Receiver: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
Receiver: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc",
|
||||||
KavaERC20Address: contractAddr.String(),
|
ZgChainERC20Address: contractAddr.String(),
|
||||||
Amount: sdkmath.NewInt(12e8),
|
Amount: sdkmath.NewInt(12e8),
|
||||||
},
|
},
|
||||||
userErc20Balance: sdkmath.NewInt(2e18),
|
userErc20Balance: sdkmath.NewInt(2e18),
|
||||||
@ -228,7 +228,7 @@ func (suite *MsgServerSuite) TestConvertERC20ToCoin_Bep3() {
|
|||||||
msg: types.MsgConvertERC20ToCoin{
|
msg: types.MsgConvertERC20ToCoin{
|
||||||
Initiator: invoker.String(),
|
Initiator: invoker.String(),
|
||||||
Receiver: invokerCosmosAddr.String(),
|
Receiver: invokerCosmosAddr.String(),
|
||||||
KavaERC20Address: invokerCosmosAddr.String(),
|
ZgChainERC20Address: invokerCosmosAddr.String(),
|
||||||
Amount: sdkmath.NewInt(12e8),
|
Amount: sdkmath.NewInt(12e8),
|
||||||
},
|
},
|
||||||
userErc20Balance: sdkmath.NewInt(2e18),
|
userErc20Balance: sdkmath.NewInt(2e18),
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
package types
|
|
||||||
|
|
||||||
// MoneyMarketInterestRates is a slice of MoneyMarketInterestRate
|
|
||||||
type MoneyMarketInterestRates []MoneyMarketInterestRate
|
|
||||||
|
|
||||||
// InterestFactors is a slice of InterestFactor
|
|
||||||
type InterestFactors []InterestFactor
|
|
Loading…
Reference in New Issue
Block a user