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

feat: fix issues and add test cases for payment #348

Merged
merged 36 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
325e944
feat: add testcases for payment related modules
forcodedancing Jul 13, 2023
a44ca26
add testcases and refactor
forcodedancing Jul 14, 2023
9f8c7df
add some query apis
forcodedancing Jul 14, 2023
44e4e40
add some tests related to virtual group
forcodedancing Jul 14, 2023
47784ff
add metrics
forcodedancing Jul 14, 2023
32b4d56
fix issues and add tests
forcodedancing Jul 17, 2023
fc40bd8
fix lint issues
forcodedancing Jul 17, 2023
aa305c9
fix force delete buckets with frozen account issue
forcodedancing Jul 17, 2023
6640a82
Merge branch 'develop' into payment_refine
forcodedancing Jul 17, 2023
3b89c12
fix test issue
forcodedancing Jul 17, 2023
4d52a12
fix unit test
forcodedancing Jul 17, 2023
64d9fb0
handle frozen account
forcodedancing Jul 18, 2023
8eda124
add some payment test cases
forcodedancing Jul 18, 2023
90932ef
fix lint issue
forcodedancing Jul 18, 2023
471b5d5
remove some debug logs
forcodedancing Jul 19, 2023
5828b26
1. add copy object testcase
MockY-B Jul 19, 2023
0e92406
Merge branch 'develop' into payment_refine
forcodedancing Jul 19, 2023
5ab6d78
add e2e cases for discontinue
forcodedancing Jul 19, 2023
cefaa0b
try to make tests stable
forcodedancing Jul 20, 2023
44d38d4
Merge branch 'develop' into payment_refine
forcodedancing Jul 20, 2023
99e9388
add tests and update logic
forcodedancing Jul 20, 2023
c47444f
refactor codes
forcodedancing Jul 20, 2023
3240d42
fix get stat of sp panic
fynnss Jul 20, 2023
bb328f1
fix vg test
fynnss Jul 20, 2023
ebc183c
fix an issue
forcodedancing Jul 20, 2023
efa923a
1. add TestStorageBill_MigrationBucket
MockY-B Jul 20, 2023
0e49a97
fix ut
forcodedancing Jul 20, 2023
1ea7cb7
fix calculation precision issue
forcodedancing Jul 20, 2023
170499f
refine query api
forcodedancing Jul 20, 2023
dad678c
1. fix TestStorageBill_MigrationBucket assertion
MockY-B Jul 20, 2023
f353db6
1. add price change with TestStorageBill_MigrationBucket assertion
MockY-B Jul 21, 2023
3aab41a
fix some review comments
forcodedancing Jul 21, 2023
ce9eb18
fix some review comments
forcodedancing Jul 21, 2023
90924e1
1. use transfer BNB with TestStorageBill_MigrationBucket assertion
MockY-B Jul 21, 2023
0674e49
fix an issue
forcodedancing Jul 21, 2023
331e068
update swaggger
forcodedancing Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion app/reconciliation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package app
import (
"bytes"
"encoding/binary"
"encoding/json"
"fmt"

"cosmossdk.io/math"
paymenttypes "github.com/bnb-chain/greenfield/x/payment/types"
"github.com/cosmos/cosmos-sdk/store/iavl"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

paymenttypes "github.com/bnb-chain/greenfield/x/payment/types"
)

const reconStoreKey = "reconciliation"
Expand Down Expand Up @@ -124,6 +126,9 @@ func (app *App) reconPaymentChanges(ctx sdk.Context, paymentIavl *iavl.Store) bo
ctx.Logger().Error("fail to unmarshal stream record", "err", err.Error())
} else {
flowCurrent = flowCurrent.Add(sr.NetflowRate)
//TODO: impact performance, remove it later
j, _ := json.Marshal(sr)
yutianwu marked this conversation as resolved.
Show resolved Hide resolved
forcodedancing marked this conversation as resolved.
Show resolved Hide resolved
ctx.Logger().Debug("stream_record_current", "stream record", j, "addr", parseAddressFromStreamRecordKey(kBz))
}
}

Expand All @@ -139,6 +144,9 @@ func (app *App) reconPaymentChanges(ctx sdk.Context, paymentIavl *iavl.Store) bo
ctx.Logger().Error("fail to unmarshal stream record", "err", err.Error())
} else {
flowPre = flowPre.Add(sr.NetflowRate)
//TODO: impact performance, remove it later
j, _ := json.Marshal(sr)
ctx.Logger().Debug("stream_record_previous", "stream record", j, "addr", parseAddressFromStreamRecordKey(kBz))
}
}
}
Expand Down Expand Up @@ -196,3 +204,8 @@ func parseAmountFromValue(value []byte) math.Int {
}
return amount
}

func parseAddressFromStreamRecordKey(key []byte) string {
start := len(StreamRecordKeyPrefix)
return sdk.AccAddress(key[start:]).String()
}
6 changes: 3 additions & 3 deletions deployment/localup/localup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ function generate_genesis() {
sed -i -e "s/\"heartbeat_interval\": \"1000\"/\"heartbeat_interval\": \"100\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"attestation_inturn_interval\": \"120\"/\"attestation_inturn_interval\": \"10\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"discontinue_confirm_period\": \"604800\"/\"discontinue_confirm_period\": \"5\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"discontinue_deletion_max\": \"10000\"/\"discontinue_deletion_max\": \"1\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"voting_period\": \"30s\"/\"voting_period\": \"10s\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"discontinue_deletion_max\": \"10000\"/\"discontinue_deletion_max\": \"2\"/g" ${workspace}/.local/validator${i}/config/genesis.json
sed -i -e "s/\"voting_period\": \"30s\"/\"voting_period\": \"5s\"/g" ${workspace}/.local/validator${i}/config/genesis.json
#sed -i -e "s/\"community_tax\": \"0.020000000000000000\"/\"community_tax\": \"0\"/g" ${workspace}/.local/validator${i}/config/genesis.json
#sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml
sed -i -e "s/log_level = \"info\"/\log_level= \"debug\"/g" ${workspace}/.local/validator${i}/config/config.toml
done

# enable swagger API for validator0
Expand Down
13 changes: 11 additions & 2 deletions e2e/core/basesuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (s *BaseSuite) SendTxBlock(from keys.KeyManager, msg ...sdk.Msg) *sdk.TxRes
})
s.Require().NoError(err)

s.T().Logf("block_height: %d, tx_hash: 0x%s", getTxRes.TxResponse.Height, response.TxResponse.TxHash)
s.T().Logf("block_height: %d, tx_hash: 0x%s, GasUsed: %v", getTxRes.TxResponse.Height, response.TxResponse.TxHash, response.TxResponse.GasUsed)
return getTxRes.TxResponse
}

Expand Down Expand Up @@ -200,7 +200,7 @@ func (s *BaseSuite) SendTxBlockWithExpectErrorString(msg sdk.Msg, from keys.KeyM
}
s.Client.SetKeyManager(from)
_, err := s.Client.BroadcastTx(context.Background(), []sdk.Msg{msg}, txOpt)
s.T().Logf("tx failed, err: %s, expect error string: %s", err, expectErrorString)
s.T().Logf("tx failed, err: %v, expect error string: %s", err, expectErrorString)
s.Require().Error(err)
s.Require().True(strings.Contains(err.Error(), expectErrorString))
}
Expand Down Expand Up @@ -642,6 +642,15 @@ func (s *BaseSuite) PickStorageProvider() *StorageProvider {
return nil
}

func (s *BaseSuite) PickDifferentStorageProvider(spId uint32) *StorageProvider {
for _, sp := range s.StorageProviders {
if sp.Info.Id != spId {
return sp
}
}
return nil
}

func (s *BaseSuite) PickStorageProviderByBucketName(bucketName string) *StorageProvider {
queryHeadBucketResponse, err := s.Client.HeadBucket(context.Background(), &storagetypes.QueryHeadBucketRequest{
BucketName: bucketName,
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"time"

sdkmath "cosmossdk.io/math"
gnfdtypes "github.com/bnb-chain/greenfield/sdk/types"
"github.com/cosmos/cosmos-sdk/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/tx"
Expand All @@ -22,6 +21,7 @@ import (
"github.com/stretchr/testify/suite"

"github.com/bnb-chain/greenfield/e2e/core"
gnfdtypes "github.com/bnb-chain/greenfield/sdk/types"
types2 "github.com/bnb-chain/greenfield/sdk/types"
bridgetypes "github.com/bnb-chain/greenfield/x/bridge/types"
)
Expand Down
Loading
Loading