Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
keyleu committed Dec 11, 2023
2 parents 71e4531 + 81d44ff commit ab6c686
Show file tree
Hide file tree
Showing 26 changed files with 1,368 additions and 331 deletions.
6 changes: 5 additions & 1 deletion integration-tests/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ func DeployAndInstantiateContract(
Amount: issueFee.Amount.AddRaw(1_000_000),
})

contractClient := coreum.NewContractClient(coreum.DefaultContractClientConfig(sdk.AccAddress(nil)), chains.Log, chains.Coreum.ClientContext)
contractClient := coreum.NewContractClient(
coreum.DefaultContractClientConfig(sdk.AccAddress(nil)),
chains.Log,
chains.Coreum.ClientContext,
)
instantiationCfg := coreum.InstantiationConfig{
Owner: owner,
Admin: owner,
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/conv.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
"github.com/stretchr/testify/require"
)

// ConvertStringWithDecimalsToSDKInt accepts the float string and returns the value equal to `value * 1e(tokenDecimals)` truncate to int.
// ConvertStringWithDecimalsToSDKInt accepts the float string and returns the value equal to
// `value * 1e(tokenDecimals)` truncate to int.
func ConvertStringWithDecimalsToSDKInt(t *testing.T, stringValue string, tokenDecimals int64) sdkmath.Int {
tenPowerDec := big.NewInt(0).Exp(big.NewInt(10), big.NewInt(tokenDecimals), nil)
valueRat, ok := big.NewRat(0, 1).SetString(stringValue)
Expand Down
9 changes: 7 additions & 2 deletions integration-tests/coreum.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ type CoreumChain struct {

// NewCoreumChain returns new instance of the coreum chain.
func NewCoreumChain(cfg CoreumChainConfig) (CoreumChain, error) {
queryCtx, queryCtxCancel := context.WithTimeout(context.Background(), getTestContextConfig().TimeoutConfig.RequestTimeout)
queryCtx, queryCtxCancel := context.WithTimeout(
context.Background(),
getTestContextConfig().TimeoutConfig.RequestTimeout,
)
defer queryCtxCancel()

coreumGRPCClient := integration.DialGRPCClient(cfg.GRPCAddress)
Expand All @@ -37,7 +40,9 @@ func NewCoreumChain(cfg CoreumChainConfig) (CoreumChain, error) {
coreumClientCtx := client.NewContext(getTestContextConfig(), app.ModuleBasics).
WithGRPCClient(coreumGRPCClient)

coreumFeemodelParamsRes, err := feemodeltypes.NewQueryClient(coreumClientCtx).Params(queryCtx, &feemodeltypes.QueryParamsRequest{})
coreumFeemodelParamsRes, err := feemodeltypes.
NewQueryClient(coreumClientCtx).
Params(queryCtx, &feemodeltypes.QueryParamsRequest{})
if err != nil {
return CoreumChain{}, errors.WithStack(err)
}
Expand Down
518 changes: 405 additions & 113 deletions integration-tests/coreum/contract_client_test.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions integration-tests/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Chains struct {
Log logger.Logger
}

//nolint:lll // breaking down cli flags will make it less readable.
func init() {
flag.StringVar(&coreumCfg.GRPCAddress, "coreum-grpc-address", "localhost:9090", "GRPC address of cored node started by coreum")
flag.StringVar(&coreumCfg.FundingMnemonic, "coreum-funding-mnemonic", "sad hobby filter tray ordinary gap half web cat hard call mystery describe member round trend friend beyond such clap frozen segment fan mistake", "Funding coreum account mnemonic required by tests")
Expand Down
17 changes: 14 additions & 3 deletions integration-tests/processes/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,9 @@ func (r *RunnerEnv) AllocateTickets(
require.NoError(t, err)

r.Chains.XRPL.FundAccountForTicketAllocation(ctx, t, r.bridgeXRPLAddress, numberOfTicketsToAllocate)
_, err = r.ContractClient.RecoverTickets(ctx, r.ContractOwner, *bridgeXRPLAccountInfo.AccountData.Sequence, &numberOfTicketsToAllocate)
_, err = r.ContractClient.RecoverTickets(
ctx, r.ContractOwner, *bridgeXRPLAccountInfo.AccountData.Sequence, &numberOfTicketsToAllocate,
)
require.NoError(t, err)

require.NoError(t, err)
Expand All @@ -263,11 +265,20 @@ func (r *RunnerEnv) RegisterXRPLOriginatedToken(
r.Chains.Coreum.FundAccountWithOptions(ctx, t, r.ContractOwner, coreumintegration.BalancesOptions{
Amount: r.Chains.Coreum.QueryAssetFTParams(ctx, t).IssueFee.Amount,
})
_, err := r.ContractClient.RegisterXRPLToken(ctx, r.ContractOwner, issuer.String(), xrpl.ConvertCurrencyToString(currency), sendingPrecision, maxHoldingAmount)
_, err := r.ContractClient.RegisterXRPLToken(
ctx,
r.ContractOwner,
issuer.String(),
xrpl.ConvertCurrencyToString(currency),
sendingPrecision,
maxHoldingAmount,
)
require.NoError(t, err)
// await for the trust set
r.AwaitNoPendingOperations(ctx, t)
registeredXRPLToken, err := r.ContractClient.GetXRPLTokenByIssuerAndCurrency(ctx, issuer.String(), xrpl.ConvertCurrencyToString(currency))
registeredXRPLToken, err := r.ContractClient.GetXRPLTokenByIssuerAndCurrency(
ctx, issuer.String(), xrpl.ConvertCurrencyToString(currency),
)
require.NoError(t, err)
require.Equal(t, coreum.TokenStateEnabled, registeredXRPLToken.State)

Expand Down
Loading

0 comments on commit ab6c686

Please sign in to comment.