Clean up test suite #134
41
.github/workflows/test.yml
vendored
41
.github/workflows/test.yml
vendored
@ -94,39 +94,34 @@ jobs:
|
|||||||
ref: jest_timeout
|
ref: jest_timeout
|
||||||
- name: Environment
|
- name: Environment
|
||||||
run: ls -tlh && env
|
run: ls -tlh && env
|
||||||
- name: build containers scripts
|
- name: Build containers scripts
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
run: ./build-laconicd-container.sh && ./build-sdk-test-container.sh
|
run: ./build-laconicd-container.sh && ./build-sdk-test-container.sh
|
||||||
- name: start containers
|
|
||||||
|
- name: Start containers
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
run: docker compose up -d
|
run: docker compose up -d
|
||||||
- name: run-tests.sh
|
- name: Run tests
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
run: ./run-tests.sh
|
run: ./run-tests.sh
|
||||||
- name: reset containers for auction tests
|
|
||||||
|
- name: Start auction containers
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
if: always()
|
env:
|
||||||
run: docker compose down
|
TEST_AUCTION_ENABLED: true
|
||||||
- name: start auction containers
|
run: docker compose up -d
|
||||||
|
- name: Run auction tests
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
run: docker compose -f docker-compose-auctions.yml up -d
|
run: ./run-tests.sh test:auctions
|
||||||
- name: run-acution-tests.sh
|
|
||||||
|
- name: Start auction containers
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
run: ./run-auction-tests.sh
|
env:
|
||||||
- name: reset containers for nameservice tests
|
TEST_REGISTRY_EXPIRY: true
|
||||||
|
run: docker compose up -d
|
||||||
|
- name: Run nameservice expiry tests
|
||||||
working-directory: tests/sdk_tests
|
working-directory: tests/sdk_tests
|
||||||
if: always()
|
run: ./run-tests.sh test:nameservice-expiry
|
||||||
run: docker compose -f docker-compose-auctions.yml down
|
|
||||||
- name: start auction containers
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: docker compose -f docker-compose-nameservice.yml up -d
|
|
||||||
- name: run-nameservice-expiry-tests.sh
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./run-nameservice-expiry-tests.sh
|
|
||||||
- name: reset containers for nameservice tests
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
if: always()
|
|
||||||
run: docker compose -f docker-compose-nameservice.yml down
|
|
||||||
|
|
||||||
# integration_tests:
|
# integration_tests:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
|
2
Makefile
2
Makefile
@ -316,7 +316,7 @@ TEST_TARGETS := test-unit test-unit-cover test-race
|
|||||||
# Test runs-specific rules. To add a new test target, just add
|
# Test runs-specific rules. To add a new test target, just add
|
||||||
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
||||||
# append the new rule to the TEST_TARGETS list.
|
# append the new rule to the TEST_TARGETS list.
|
||||||
test-unit: ARGS=-timeout=10m -race
|
test-unit: ARGS=-timeout=10m -race -test.v
|
||||||
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
|
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
|
||||||
|
|
||||||
test-race: ARGS=-race
|
test-race: ARGS=-race
|
||||||
|
@ -55,7 +55,7 @@ message Params {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Params defines the registry module records
|
// Record defines a registry record
|
||||||
message Record {
|
message Record {
|
||||||
string id = 1 [(gogoproto.moretags) = "json:\"id\" yaml:\"id\""];
|
string id = 1 [(gogoproto.moretags) = "json:\"id\" yaml:\"id\""];
|
||||||
string bond_id = 2 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
string bond_id = 2 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
||||||
@ -68,7 +68,7 @@ message Record {
|
|||||||
string type = 9 [(gogoproto.moretags) = "json:\"types\" yaml:\"types\""];
|
string type = 9 [(gogoproto.moretags) = "json:\"types\" yaml:\"types\""];
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthorityEntry defines the registry module AuthorityEntries
|
// AuthorityEntry defines a registry authority
|
||||||
message AuthorityEntry {
|
message AuthorityEntry {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
NameAuthority entry = 2;
|
NameAuthority entry = 2;
|
||||||
@ -98,7 +98,7 @@ message NameEntry {
|
|||||||
NameRecord entry = 2;
|
NameRecord entry = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameRecord
|
// NameRecord defines a versioned name record
|
||||||
message NameRecord {
|
message NameRecord {
|
||||||
NameRecordEntry latest = 1;
|
NameRecordEntry latest = 1;
|
||||||
repeated NameRecordEntry history = 2;
|
repeated NameRecordEntry history = 2;
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
docker build -t cerc-io/laconicd:local-test ../../
|
docker build -t cerc/laconicd:local-test ../..
|
||||||
|
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
docker build -t cerc-io/laconic-sdk-tester:local-test -f Dockerfile-sdk .
|
docker build -t cerc/laconic-sdk-tester:local-test .
|
||||||
|
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
services:
|
|
||||||
laconicd:
|
|
||||||
restart: unless-stopped
|
|
||||||
image: cerc-io/laconicd:local-test
|
|
||||||
environment:
|
|
||||||
- TEST_AUCTION_ENABLED=true
|
|
||||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
|
||||||
volumes:
|
|
||||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
|
||||||
interval: 1s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 30
|
|
||||||
ports:
|
|
||||||
- "6060"
|
|
||||||
- "26657"
|
|
||||||
- "26656"
|
|
||||||
- "9473"
|
|
||||||
- "8545"
|
|
||||||
- "8546"
|
|
||||||
- "9090"
|
|
||||||
- "9091"
|
|
||||||
- "1317"
|
|
||||||
|
|
||||||
sdk-test-runner:
|
|
||||||
image: cerc-io/laconic-sdk-tester:local-test
|
|
||||||
depends_on:
|
|
||||||
laconicd:
|
|
||||||
condition: service_healthy
|
|
||||||
command: tail -F /dev/null
|
|
@ -1,31 +0,0 @@
|
|||||||
services:
|
|
||||||
laconicd:
|
|
||||||
restart: unless-stopped
|
|
||||||
image: cerc-io/laconicd:local-test
|
|
||||||
environment:
|
|
||||||
- TEST_REGISTRY_EXPIRY=true
|
|
||||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
|
||||||
volumes:
|
|
||||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
|
||||||
healthcheck:
|
|
||||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
|
||||||
interval: 1s
|
|
||||||
timeout: 5s
|
|
||||||
retries: 30
|
|
||||||
ports:
|
|
||||||
- "6060"
|
|
||||||
- "26657"
|
|
||||||
- "26656"
|
|
||||||
- "9473"
|
|
||||||
- "8545"
|
|
||||||
- "8546"
|
|
||||||
- "9090"
|
|
||||||
- "9091"
|
|
||||||
- "1317"
|
|
||||||
|
|
||||||
sdk-test-runner:
|
|
||||||
image: cerc-io/laconic-sdk-tester:local-test
|
|
||||||
depends_on:
|
|
||||||
laconicd:
|
|
||||||
condition: service_healthy
|
|
||||||
command: tail -F /dev/null
|
|
@ -1,8 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
laconicd:
|
laconicd:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: cerc-io/laconicd:local-test
|
image: cerc/laconicd:local-test
|
||||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||||
|
environment:
|
||||||
|
- TEST_AUCTION_ENABLED
|
||||||
|
- TEST_REGISTRY_EXPIRY
|
||||||
volumes:
|
volumes:
|
||||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@ -22,7 +25,7 @@ services:
|
|||||||
- "1317"
|
- "1317"
|
||||||
|
|
||||||
sdk-test-runner:
|
sdk-test-runner:
|
||||||
image: cerc-io/laconic-sdk-tester:local-test
|
image: cerc/laconic-sdk-tester:local-test
|
||||||
depends_on:
|
depends_on:
|
||||||
laconicd:
|
laconicd:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
# Get the key from laconicd
|
|
||||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
|
||||||
# Set parameters for the test suite
|
|
||||||
cosmos_chain_id=laconic_9000-1
|
|
||||||
laconicd_rest_endpoint=http://laconicd:1317
|
|
||||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
|
||||||
# Run tests
|
|
||||||
docker network inspect sdk_tests_default
|
|
||||||
sleep 30s
|
|
||||||
docker logs sdk_tests-laconicd-1
|
|
||||||
|
|
||||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:auctions"
|
|
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
# Get the key from laconicd
|
|
||||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
|
||||||
# Set parameters for the test suite
|
|
||||||
cosmos_chain_id=laconic_9000-1
|
|
||||||
laconicd_rest_endpoint=http://laconicd:1317
|
|
||||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
|
||||||
# Run tests
|
|
||||||
docker network inspect sdk_tests_default
|
|
||||||
sleep 30s
|
|
||||||
docker logs sdk_tests-laconicd-1
|
|
||||||
|
|
||||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:nameservice-expiry"
|
|
@ -2,16 +2,23 @@
|
|||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
yarn_args=("--inspect-brk=8888")
|
||||||
|
yarn_args+=("${@:-test}")
|
||||||
|
|
||||||
# Get the key from laconicd
|
# Get the key from laconicd
|
||||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
laconicd_key=$(
|
||||||
|
yes | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe
|
||||||
|
)
|
||||||
# Set parameters for the test suite
|
# Set parameters for the test suite
|
||||||
cosmos_chain_id=laconic_9000-1
|
cosmos_chain_id=laconic_9000-1
|
||||||
laconicd_rest_endpoint=http://laconicd:1317
|
laconicd_rest_endpoint=http://laconicd:1317
|
||||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||||
# Run tests
|
|
||||||
docker network inspect sdk_tests_default
|
|
||||||
docker compose logs laconicd
|
|
||||||
docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api"
|
|
||||||
docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://localhost:9473/api"
|
|
||||||
|
|
||||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test"
|
# Run tests
|
||||||
|
docker compose exec \
|
||||||
|
-e COSMOS_CHAIN_ID="$cosmos_chain_id" \
|
||||||
|
-e LACONICD_REST_ENDPOINT="$laconicd_rest_endpoint" \
|
||||||
|
-e LACONICD_GQL_ENDPOINT="$laconicd_gql_endpoint" \
|
||||||
|
-e PRIVATE_KEY="$laconicd_key" \
|
||||||
|
sdk-test-runner yarn run "${yarn_args[@]}"
|
||||||
|
@ -519,6 +519,7 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
|||||||
|
|
||||||
l.Log("starting test network...")
|
l.Log("starting test network...")
|
||||||
for _, v := range network.Validators {
|
for _, v := range network.Validators {
|
||||||
|
l.Log("starting validator:", v.Moniker)
|
||||||
err := startInProcess(cfg, v)
|
err := startInProcess(cfg, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -44,7 +44,8 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -112,11 +113,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
tc.url = fmt.Sprintf(tc.url, authorityName)
|
tc.url = fmt.Sprintf(tc.url, authorityName)
|
||||||
}
|
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -133,7 +134,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
|||||||
func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup?crn=%s"
|
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup"
|
||||||
authorityName := "QueryLookUp"
|
authorityName := "QueryLookUp"
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -153,7 +154,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Success",
|
"Success",
|
||||||
reqURL,
|
fmt.Sprintf(reqURL+"?crn=crn://%s/", authorityName),
|
||||||
false,
|
false,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -165,11 +166,9 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
tc.url = fmt.Sprintf(reqURL, fmt.Sprintf("crn://%s/", authorityName))
|
resp, err := rest.GetRequest(tc.url)
|
||||||
}
|
s.NoError(err)
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
sr.Contains(string(resp), tc.errorMsg)
|
sr.Contains(string(resp), tc.errorMsg)
|
||||||
} else {
|
} else {
|
||||||
@ -235,12 +234,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
}
|
|
||||||
// wait 12 seconds for records expires
|
// wait 12 seconds for records expires
|
||||||
time.Sleep(time.Second * 12)
|
time.Sleep(time.Second * 12)
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -305,13 +303,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun("QueryAuthorityExpiryQueue")
|
tc.preRun("QueryAuthorityExpiryQueue")
|
||||||
}
|
|
||||||
// wait 12 seconds to name authorites expires
|
// wait 12 seconds to name authorites expires
|
||||||
time.Sleep(time.Second * 12)
|
time.Sleep(time.Second * 12)
|
||||||
|
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -379,10 +376,9 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
}
|
resp, err := rest.GetRequest(tc.url)
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -445,12 +441,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByID() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
var recordID string
|
recordID := tc.preRun(s.bondID)
|
||||||
if !tc.expectErr {
|
|
||||||
recordID = tc.preRun(s.bondID)
|
|
||||||
tc.url = fmt.Sprintf(reqURL, recordID)
|
tc.url = fmt.Sprintf(reqURL, recordID)
|
||||||
}
|
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -500,11 +495,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
||||||
}
|
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
resp, err := rest.GetRequest(tc.url)
|
||||||
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -554,10 +549,9 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRegistryModuleBalance() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
}
|
resp, err := rest.GetRequest(tc.url)
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -605,10 +599,9 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
if !tc.expectErr {
|
|
||||||
tc.preRun("ListNameRecords")
|
tc.preRun("ListNameRecords")
|
||||||
}
|
resp, err := rest.GetRequest(tc.url)
|
||||||
resp, _ := rest.GetRequest(tc.url)
|
s.NoError(err)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -645,5 +638,5 @@ func createRecord(bondID string, s *IntegrationTestSuite) {
|
|||||||
var d sdk.TxResponse
|
var d sdk.TxResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code, d.RawLog)
|
||||||
}
|
}
|
||||||
|
@ -538,9 +538,6 @@ func createNameRecord(authorityName string, s *IntegrationTestSuite) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
// creating the bond
|
|
||||||
CreateBond(s)
|
|
||||||
|
|
||||||
// Get the bond-id
|
// Get the bond-id
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
|
|
||||||
|
@ -101,43 +101,24 @@ func CreateBond(s *IntegrationTestSuite) {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
|
|
||||||
testCases := []struct {
|
clientCtx := val.ClientCtx
|
||||||
name string
|
cmd := bondcli.NewCreateBondCmd()
|
||||||
args []string
|
args := []string{
|
||||||
err bool
|
|
||||||
}{
|
|
||||||
{
|
|
||||||
"create bond",
|
|
||||||
[]string{
|
|
||||||
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||||
},
|
|
||||||
false,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||||
for _, tc := range testCases {
|
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
|
||||||
clientCtx := val.ClientCtx
|
|
||||||
cmd := bondcli.NewCreateBondCmd()
|
|
||||||
|
|
||||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
|
||||||
if tc.err {
|
|
||||||
sr.Error(err)
|
|
||||||
} else {
|
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
|
|
||||||
var d sdk.TxResponse
|
var d sdk.TxResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetBondID(s *IntegrationTestSuite) string {
|
func GetBondID(s *IntegrationTestSuite) string {
|
||||||
cmd := bondcli.GetQueryBondLists()
|
cmd := bondcli.GetQueryBondLists()
|
||||||
@ -160,6 +141,11 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
|
|
||||||
|
bondID := GetBondID(s)
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
sr.NoError(err)
|
||||||
|
payloadPath := dir + "/service_provider_example.yml"
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@ -179,6 +165,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
{
|
{
|
||||||
"success",
|
"success",
|
||||||
[]string{
|
[]string{
|
||||||
|
payloadPath, bondID,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -191,17 +178,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
if !tc.err {
|
|
||||||
// create the bond
|
|
||||||
CreateBond(s)
|
|
||||||
// get the bond id from bond list
|
|
||||||
bondID := GetBondID(s)
|
|
||||||
dir, err := os.Getwd()
|
|
||||||
sr.NoError(err)
|
|
||||||
payloadPath := dir + "/service_provider_example.yml"
|
|
||||||
|
|
||||||
tc.args = append([]string{payloadPath, bondID}, tc.args...)
|
|
||||||
}
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetRecord()
|
cmd := cli.GetCmdSetRecord()
|
||||||
|
|
||||||
@ -341,9 +317,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
// creating the bond
|
|
||||||
CreateBond(s)
|
|
||||||
|
|
||||||
// Get the bond-id
|
// Get the bond-id
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
|
|
||||||
@ -369,9 +342,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
if !tc.err {
|
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
}
|
|
||||||
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetName()
|
cmd := cli.GetCmdSetName()
|
||||||
@ -394,6 +365,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
authorityName := "TestGetCmdSetAuthorityBond"
|
authorityName := "TestGetCmdSetAuthorityBond"
|
||||||
|
bondID := GetBondID(s)
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@ -417,6 +389,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
{
|
{
|
||||||
"success with name and bond-id",
|
"success with name and bond-id",
|
||||||
[]string{
|
[]string{
|
||||||
|
authorityName, bondID,
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -449,15 +422,7 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
if !tc.err {
|
|
||||||
// reserve the name
|
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
// creating the bond
|
|
||||||
CreateBond(s)
|
|
||||||
// getting the bond-id
|
|
||||||
bondID := GetBondID(s)
|
|
||||||
tc.args = append([]string{authorityName, bondID}, tc.args...)
|
|
||||||
}
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetAuthorityBond()
|
cmd := cli.GetCmdSetAuthorityBond()
|
||||||
|
|
||||||
@ -501,6 +466,7 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
|||||||
{
|
{
|
||||||
"successfully delete name",
|
"successfully delete name",
|
||||||
[]string{
|
[]string{
|
||||||
|
fmt.Sprintf("crn://%s/", authorityName),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -516,10 +482,8 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
|||||||
|
|
||||||
for _, tc := range testCasesForDeletingName {
|
for _, tc := range testCasesForDeletingName {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
if !tc.err {
|
|
||||||
tc.preRun(authorityName, s)
|
tc.preRun(authorityName, s)
|
||||||
tc.args = append([]string{fmt.Sprintf("crn://%s/", authorityName)}, tc.args...)
|
|
||||||
}
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdDeleteName()
|
cmd := cli.GetCmdDeleteName()
|
||||||
|
|
||||||
@ -574,8 +538,6 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(s *IntegrationTestSuite) string {
|
func(s *IntegrationTestSuite) string {
|
||||||
// create the bond
|
|
||||||
CreateBond(s)
|
|
||||||
// get the bond id from bond list
|
// get the bond id from bond list
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
@ -816,8 +778,6 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(s *IntegrationTestSuite) (string, string) {
|
func(s *IntegrationTestSuite) (string, string) {
|
||||||
// create the bond
|
|
||||||
CreateBond(s)
|
|
||||||
// get the bond id from bond list
|
// get the bond id from bond list
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
|
@ -25,11 +25,7 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
record, err := m.Keeper.ProcessSetRecord(ctx, types.MsgSetRecord{
|
record, err := m.Keeper.ProcessSetRecord(ctx, *msg)
|
||||||
|
|||||||
BondId: msg.GetBondId(),
|
|
||||||
Signer: msg.GetSigner(),
|
|
||||||
Payload: msg.GetPayload(),
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user
The changes to this file look fine, but I'm not sure how they are related to test cleanup.
Cleanup change coming from original PR cerc-io/laconicd#111.
I think the same question applies, but it may not be worth splitting out into a separate PR.