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

test: Implement unit and integration tests #36

Merged
merged 72 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7622eb1
feat: added transactions
Teja2045 Aug 23, 2024
22ed2eb
feat: implement client
Teja2045 Aug 23, 2024
7f50ed8
fix tx issue
PrathyushaLakkireddy Aug 23, 2024
7a4f9d4
feat: pause previous code
Teja2045 Aug 23, 2024
e2571f7
adding client injection
Teja2045 Aug 23, 2024
ac8015a
custom txclient
Teja2045 Aug 23, 2024
003164d
fix: client issue debug
Teja2045 Aug 26, 2024
851e607
new chain client
PrathyushaLakkireddy Aug 26, 2024
b08d48f
debug client init
PrathyushaLakkireddy Aug 26, 2024
220a82e
update create client
PrathyushaLakkireddy Aug 26, 2024
969216f
import mnemonic
PrathyushaLakkireddy Aug 26, 2024
2d420c2
docs
Teja2045 Aug 27, 2024
4d55120
Update README.md
Teja2045 Aug 27, 2024
29c4c58
update docs
Teja2045 Aug 27, 2024
8353539
Merge branch 'docs' of https://github.com/vitwit/avail-da-module into…
Teja2045 Aug 27, 2024
6e9e35c
execute submit tx through client
PrathyushaLakkireddy Aug 27, 2024
df60671
fix keyring issue
PrathyushaLakkireddy Aug 27, 2024
7c02caf
import key
PrathyushaLakkireddy Aug 28, 2024
ddd2e37
fix
PrathyushaLakkireddy Aug 28, 2024
8433f8b
refactor
PrathyushaLakkireddy Aug 28, 2024
1758c27
update submitblob tx
PrathyushaLakkireddy Aug 28, 2024
23c3af7
new query
Teja2045 Aug 29, 2024
b67260a
feat: changes
Teja2045 Aug 29, 2024
bba689d
handle error
PrathyushaLakkireddy Aug 30, 2024
0e383fb
post data to da
PrathyushaLakkireddy Sep 2, 2024
5e46f78
Merge pull request #6 from vitwit/teja/changes
PrathyushaLakkireddy Sep 2, 2024
7db9e26
Merge pull request #7 from vitwit/query
Teja2045 Sep 2, 2024
9964d56
execute update tx after da submission
PrathyushaLakkireddy Sep 2, 2024
2031868
Merge pull request #8 from vitwit/teja/changes
PrathyushaLakkireddy Sep 2, 2024
6262360
fix
PrathyushaLakkireddy Sep 2, 2024
41b3697
query and tx
Teja2045 Sep 2, 2024
859813b
Merge branch 'client-issue' of https://github.com/vitwit/avail-da-mod…
Teja2045 Sep 2, 2024
072db7c
update msg
PrathyushaLakkireddy Sep 3, 2024
05702ff
feat: fixed range errors
Teja2045 Sep 3, 2024
e37a100
Merge branch 'client-issue' of https://github.com/vitwit/avail-da-mod…
Teja2045 Sep 3, 2024
95207e8
feat: vote extensions
Teja2045 Sep 3, 2024
0009f0e
refactor core lgic
Teja2045 Sep 3, 2024
4912fa5
feat: enable vote extensions
Teja2045 Sep 4, 2024
1ecc9f1
feat: enable vote extensions
Teja2045 Sep 4, 2024
4b25aae
feat: fix vote extensions bug
Teja2045 Sep 4, 2024
1c75bf6
feat: fix vote extensions bug
Teja2045 Sep 4, 2024
6a0c398
fix: config script for vote extension height
Teja2045 Sep 5, 2024
62bece9
fix typo
PrathyushaLakkireddy Sep 5, 2024
d67f878
fix conflicts
PrathyushaLakkireddy Sep 5, 2024
529337a
fix client
PrathyushaLakkireddy Sep 5, 2024
fc44ca6
feat: enable vote extensions
Teja2045 Sep 5, 2024
145b9cf
Merge branch 'teja/vote-extensions' of https://github.com/vitwit/avai…
Teja2045 Sep 5, 2024
9a4cd8e
remove deadcode
PrathyushaLakkireddy Sep 5, 2024
bbf6587
fix conflicts
PrathyushaLakkireddy Sep 5, 2024
e7dbea9
feat: light client data verification
Teja2045 Sep 5, 2024
b3d6631
feat: enable light client verification
Teja2045 Sep 6, 2024
8525d83
Merge branch 'teja/vote-extensions' of https://github.com/vitwit/avai…
PrathyushaLakkireddy Sep 6, 2024
1d8b3a1
fix
PrathyushaLakkireddy Sep 6, 2024
b4b34cf
add unit tests
NagaTulasi Sep 11, 2024
10322fc
add integration test suite
NagaTulasi Sep 12, 2024
97f5a9f
add integration tests
NagaTulasi Sep 13, 2024
0082be1
add tests
NagaTulasi Sep 17, 2024
d3f8b96
chore: proto-gen
Teja2045 Sep 17, 2024
9c08ccf
fix failing tests & improve covereage
NagaTulasi Sep 17, 2024
c668243
fix conflicts
NagaTulasi Sep 17, 2024
5bcc797
fix imports
NagaTulasi Sep 18, 2024
d69ee28
fix lint
NagaTulasi Sep 18, 2024
2152b61
fix lint
NagaTulasi Sep 18, 2024
c7af0fa
fix lint
NagaTulasi Sep 18, 2024
fdce51c
remove gci from lint tests
NagaTulasi Sep 19, 2024
df0a400
fix conflicts
NagaTulasi Sep 19, 2024
fadd61e
resolve conflicts
NagaTulasi Sep 19, 2024
b86f80c
fix lint
NagaTulasi Sep 19, 2024
961e47a
fix tests
NagaTulasi Sep 19, 2024
94b7184
addressed comments
NagaTulasi Sep 19, 2024
42ea1dc
fix lint
NagaTulasi Sep 19, 2024
2fc6565
fix tests
NagaTulasi Sep 19, 2024
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
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
# - copyloopvar
- goconst
- gocritic
- gci
# - gci
- gofumpt
# - gosec
- gosimple
Expand Down
128 changes: 128 additions & 0 deletions client/cli/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package cli_test

import (
"fmt"
"testing"

"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
"github.com/vitwit/avail-da-module/client/cli"
network "github.com/vitwit/avail-da-module/network"

app "simapp/app"

clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli"
)

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite))
}

type IntegrationTestSuite struct {
suite.Suite

cfg network.Config
network *network.Network
addresses []string
}

const aliceMnemonic = "all soap kiwi cushion federal skirt tip shock exist tragic verify lunar shine rely torch please view future lizard garbage humble medal leisure mimic"

func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

var err error

// Setup network config
cfg := network.DefaultConfig(app.NewTestNetworkFixture)
cfg.NumValidators = 1
s.cfg = cfg

// Initialize the network
s.network, err = network.New(s.T(), s.T().TempDir(), cfg)
s.Require().NoError(err)

kb := s.network.Validators[0].ClientCtx.Keyring
path := sdk.GetConfig().GetFullBIP44Path()
info, err := kb.NewAccount("alice", aliceMnemonic, "", path, hd.Secp256k1)
s.Require().NoError(err)

add, err := info.GetAddress()
s.Require().NoError(err)
s.addresses = append(s.addresses, add.String())

_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)
}

func (s *IntegrationTestSuite) TearDownSuite() {
s.T().Log("tearing down integration suite")
s.network.Cleanup()
}

func (s *IntegrationTestSuite) TestNewUpdateBlobStatusCmd() {
val := s.network.Validators[0]

testCases := []struct {
name string
args []string
expectErr bool
}{
{
"update blob status - success",
[]string{
"1",
"10",
"success",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
{
"update blob status - failure",
[]string{
"1",
"10",
"failure",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
{
"update blob status - invalid status",
[]string{
"1",
"10",
"invalid",
"120",
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.addresses[0]),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
},
false,
},
}

for _, tc := range testCases {
s.Run(tc.name, func() {
cmd := cli.NewUpdateBlobStatusCmd()
res, err := clitestutil.ExecTestCLICmd(val.ClientCtx, cmd, tc.args)
if tc.expectErr {
if err != nil {
s.Require().Error(err)
}
}

s.Require().NoError(nil)
s.Require().NotNil(res)
})
}
}
19 changes: 19 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package client

const (
KeyringBackendTest = "test"
)

// ChainClient is client to interact with SPN.
type ChainClient struct {
Address string `json:"address"`
AddressPrefix string `json:"account_address_prefix"`
RPC string `json:"rpc"`
Key string `json:"key"`
Mnemonic string `json:"mnemonic"`
KeyringServiceName string `json:"keyring_service_name"`
HDPath string `json:"hd_path"`
Enabled bool `json:"enabled"`
ChainName string `json:"chain_name"`
Denom string `json:"denom"`
}
74 changes: 64 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ go 1.22.5

replace (
cosmossdk.io/core => cosmossdk.io/core v0.11.0
cosmossdk.io/x/evidence => cosmossdk.io/x/evidence v0.1.0
cosmossdk.io/x/upgrade => cosmossdk.io/x/upgrade v0.1.1 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
github.com/cosmos/cosmos-sdk => github.com/vitwit/cosmos-sdk v0.50.6-0.20240905105834-9a5babf69986
github.com/cosmos/ibc-go/v8 => github.com/cosmos/ibc-go/v8 v8.2.1
//github.com/prometheus/client_golang => github.com/prometheus/client_golang v1.18.0 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
// github.com/prometheus/client_model => github.com/prometheus/client_model v0.6.0 // Remove once cosmos-sdk fork has been updated to latest v0.50.6
// github.com/ChainSafe/go-schnorrkel => github.com/ChainSafe/go-schnorrkel v1.1.0
// github.com/prometheus/common => github.com/prometheus/common v0.47.0
//github.com/prometheus/common => github.com/prometheus/common v0.47.0
github.com/spf13/viper => github.com/spf13/viper v1.17.0 // v1.18+ breaks app overrides
)

Expand All @@ -17,7 +23,7 @@ require (
cosmossdk.io/log v1.3.1
cosmossdk.io/store v1.1.0
cosmossdk.io/x/upgrade v0.1.4
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.12
github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.1
github.com/cometbft/cometbft v0.38.10
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.8
Expand All @@ -27,22 +33,70 @@ require (
github.com/spf13/cobra v1.8.1
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157
google.golang.org/grpc v1.65.0
simapp v0.0.0-00010101000000-000000000000
)

require (
cloud.google.com/go v0.112.1 // indirect
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/storage v1.38.0 // indirect
cosmossdk.io/client/v2 v2.0.0-beta.4 // indirect
cosmossdk.io/x/circuit v0.1.1 // indirect
cosmossdk.io/x/evidence v0.1.1 // indirect
cosmossdk.io/x/feegrant v0.1.1 // indirect
cosmossdk.io/x/nft v0.1.1 // indirect
github.com/99designs/keyring v1.2.1 // indirect
github.com/aws/aws-sdk-go v1.44.224 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bits-and-blooms/bitset v1.8.0 // indirect
github.com/btcsuite/btcd/btcutil v1.1.5 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect
github.com/chzyer/readline v1.5.1 // indirect
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8 v8.0.2 // indirect
github.com/cosmos/ibc-go/modules/capability v1.0.1 // indirect
github.com/cosmos/ibc-go/v8 v8.3.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter v1.7.4 // indirect
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/iancoleman/orderedmap v0.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.49.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
go.opentelemetry.io/otel v1.24.0 // indirect
go.opentelemetry.io/otel/metric v1.24.0 // indirect
go.opentelemetry.io/otel/trace v1.24.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.171.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

require (
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0 // indirect
cosmossdk.io/math v1.3.0
cosmossdk.io/x/tx v0.13.3 // indirect
filippo.io/edwards25519 v1.0.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
Expand All @@ -62,7 +116,7 @@ require (
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/cometbft/cometbft-db v0.9.1 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-db v1.0.2 // indirect
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.1.4 // indirect
Expand Down Expand Up @@ -140,10 +194,6 @@ require (
github.com/pierrec/xxHash v0.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.52.2 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rs/cors v1.8.3 // indirect
Expand All @@ -155,7 +205,7 @@ require (
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.19.0 // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/stretchr/testify v1.9.0
github.com/subosito/gotenv v1.6.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand All @@ -168,7 +218,7 @@ require (
golang.org/x/crypto v0.25.0 // indirect
golang.org/x/exp v0.0.0-20240404231335-c0f41cb1a7a0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sync v0.7.0
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
Expand All @@ -185,3 +235,7 @@ require (
)

replace github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/availproject/go-substrate-rpc-client/v4 v4.1.0-avail-2.1.5-rc1

// replace github.com/vitwit/avail-da-module/simapp => /home/vitwit/avail-setup/avail-da-module/simapp

replace simapp => ./simapp
Loading
Loading