Skip to content
This repository has been archived by the owner on Dec 21, 2022. It is now read-only.

open CI and fix UT #12

Merged
merged 20 commits into from
Apr 27, 2020
166 changes: 12 additions & 154 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
version: 2.1

executors:
golang:
docker:
- image: circleci/golang:1.13
docs:
docker:
- image: tendermintdev/docker-website-deployment
environment:
AWS_REGION: us-east-1

commands:
make:
parameters:
Expand All @@ -35,8 +25,10 @@ commands:
make << parameters.target >>

jobs:
setup_dependencies:
executor: golang
build:
docker:
- image: circleci/golang:1.13
working_directory: /go/src/github.com/{{ORG_NAME}}/{{REPO_NAME}}
steps:
- checkout
- restore_cache:
Expand All @@ -47,11 +39,13 @@ jobs:
name: Cache go modules
command: make go-mod-cache
- run:
name: Build
command: make build
- run:
name: Git garbage collection
command: git gc
name: Run tests
command: |
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
export GO111MODULE=on
for pkg in $(go list ./... | grep -v staking | grep -v distribution | grep -v gov | grep -v params | circleci tests split); do
go test -mod=readonly -tags='ledger test_ledger_mock' "$pkg"
done
- save_cache:
name: "Save go modules cache"
key: go-mod-v1-{{ checksum "go.sum" }}
Expand All @@ -61,140 +55,4 @@ jobs:
name: "Save source code cache"
key: go-src-v1-{{ .Revision }}
paths:
- ".git"

test_sim_nondeterminism:
executor: golang
steps:
- make:
target: test_sim_nondeterminism
description: "Test individual module simulations"

test_sim_import_export:
executor: golang
steps:
- make:
target: test_sim_import_export
description: "Test application import/export simulation"

test_sim_after_import:
executor: golang
steps:
- make:
target: test_sim_after_import
description: "Test simulation after import"

test_sim_multi_seed_long:
executor: golang
steps:
- make:
target: test_sim_multi_seed_long
description: "Test multi-seed simulation (long)"

test_sim_multi_seed_short:
executor: golang
steps:
- make:
target: test_sim_multi_seed_short
description: "Test multi-seed simulation (short)"

test_cover:
executor: golang
parallelism: 4
steps:
- checkout
- restore_cache:
keys:
- go-mod-v1-{{ checksum "go.sum" }}
- run:
name: Run tests
command: |
export VERSION="$(git describe --tags --long | sed 's/v\(.*\)/\1/')"
export GO111MODULE=on
mkdir -p /tmp/logs /tmp/workspace/profiles
for pkg in $(go list ./... | grep -v '/simulation' | circleci tests split); do
id=$(echo "$pkg" | sed 's|[/.]|_|g')
go test -mod=readonly -timeout 8m -race -coverprofile=/tmp/workspace/profiles/$id.out -covermode=atomic -tags='ledger test_ledger_mock' "$pkg" | tee "/tmp/logs/$id-$RANDOM.log"
done
- persist_to_workspace:
root: /tmp/workspace
paths:
- "profiles/*"
- store_artifacts:
path: /tmp/logs

upload_coverage:
executor: golang
steps:
- attach_workspace:
at: /tmp/workspace
- checkout
- run:
name: gather
command: |
echo "--> Concatenating profiles:"
ls /tmp/workspace/profiles/
echo "mode: atomic" > coverage.txt
for prof in $(ls /tmp/workspace/profiles/); do
tail -n +2 /tmp/workspace/profiles/"$prof" >> coverage.txt
done
- run:
name: filter out DONTCOVER
command: |
excludelist="$(find ./ -type f -name '*.go' | xargs grep -l 'DONTCOVER' | xargs realpath --relative-to=$GOPATH/src)"
for filename in ${excludelist}; do
echo "Excluding ${filename} ..."
sed -i "\%${filename}:%d" coverage.txt
done
- run:
name: upload
command: bash <(curl -s https://codecov.io/bash) -f coverage.txt

check_statik:
executor: golang
steps:
- make:
target: update-swagger-docs
description: "Check if statik.go is up-to-date"

workflows:
version: 2
test-suite:
jobs:
- check_statik:
requires:
- setup_dependencies
- setup_dependencies:
# This filter enables the job for tags
filters:
tags:
only:
- /^v.*/
- test_sim_nondeterminism:
requires:
- setup_dependencies
- test_sim_import_export:
requires:
- setup_dependencies
- test_sim_after_import:
requires:
- setup_dependencies
- test_sim_multi_seed_short:
requires:
- setup_dependencies
- test_sim_multi_seed_long:
requires:
- setup_dependencies
# These filters ensure that the long sim only runs during release
filters:
branches:
ignore: /.*/
tags:
only:
- /^v.*/
- test_cover:
requires:
- setup_dependencies
- upload_coverage:
requires:
- test_cover
- ".git"
7 changes: 5 additions & 2 deletions baseapp/baseapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,11 @@ func (app *BaseApp) DeliverTx(req abci.RequestDeliverTx) (res abci.ResponseDeliv

// validateBasicTxMsgs executes basic validator calls for messages.
func validateBasicTxMsgs(msgs []sdk.Msg) sdk.Error {
if msgs == nil || len(msgs) != 1 {
return sdk.ErrUnknownRequest("Tx.GetMsgs() must return only one message")
//if msgs == nil || len(msgs) != 1 {
// return sdk.ErrUnknownRequest("Tx.GetMsgs() must return only one message")
//}
if msgs == nil || len(msgs) == 0 {
return sdk.ErrUnknownRequest("Tx.GetMsgs() must return at least one message in list")
}

for _, msg := range msgs {
Expand Down
2 changes: 1 addition & 1 deletion client/keys/add_ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ func Test_runAddCmdLedger(t *testing.T) {
assert.Equal(t, "keyname1", key1.GetName())
assert.Equal(t, keys.TypeLedger, key1.GetType())
assert.Equal(t,
"cosmospub1addwnpepqd87l8xhcnrrtzxnkql7k55ph8fr9jarf4hn6udwukfprlalu8lgw0urza0",
"okchainpub1addwnpepqd87l8xhcnrrtzxnkql7k55ph8fr9jarf4hn6udwukfprlalu8lgwxtwrat",
sdk.MustBech32ifyAccPub(key1.GetPubKey()))
}
2 changes: 1 addition & 1 deletion client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Test_multiSigKey_Properties(t *testing.T) {
assert.Equal(t, "myMultisig", tmp.GetName())
assert.Equal(t, keys.TypeMulti, tmp.GetType())
assert.Equal(t, "D3923267FA8A3DD367BB768FA8BDC8FF7F89DA3F", tmp.GetPubKey().Address().String())
assert.Equal(t, "cosmos16wfryel63g7axeamw68630wglalcnk3l0zuadc", tmp.GetAddress().String())
assert.Equal(t, "okchain16wfryel63g7axeamw68630wglalcnk3ldcxdmm", tmp.GetAddress().String())
}

func Test_showKeysCmd(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions crypto/keys/hd/hdpath_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func ExampleStringifyPathParams() {

func TestStringifyFundraiserPathParams(t *testing.T) {
path := NewFundraiserParams(4, types.CoinType, 22)
require.Equal(t, "44'/118'/4'/0/22", path.String())
require.Equal(t, "44'/996'/4'/0/22", path.String())

path = NewFundraiserParams(4, types.CoinType, 57)
require.Equal(t, "44'/118'/4'/0/57", path.String())
require.Equal(t, "44'/996'/4'/0/57", path.String())

path = NewFundraiserParams(4, 12345, 57)
require.Equal(t, "44'/12345'/4'/0/57", path.String())
Expand Down Expand Up @@ -173,7 +173,7 @@ func ExampleSomeBIP32TestVecs() {

// Output: keys from fundraiser test-vector (cosmos, bitcoin, ether)
//
// bfcb217c058d8bbafd5e186eae936106ca3e943889b0b4a093ae13822fd3170c
// c2c0034632383a9c3e4ed8254ba86ad42b71117a876e1dcfc2be83f835fbcf76
// e77c3de76965ad89997451de97b95bb65ede23a6bf185a55d80363d92ee37c3d
// 7fc4d8a8146dea344ba04c593517d3f377fa6cded36cd55aee0a0bb968e651bc
// INVALID
Expand Down
34 changes: 17 additions & 17 deletions crypto/keys/keybase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {

func TestLanguage(t *testing.T) {
kb := NewInMemory()
_, _, err := kb.CreateMnemonic("something", Japanese, "no_pass", Secp256k1)
_, _, err := kb.CreateMnemonic("something", Japanese, "no_pass", Secp256k1, "")
assert.Error(t, err)
assert.Equal(t, "unsupported language: only english is supported", err.Error())
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestCreateLedger(t *testing.T) {
pubKey := ledger.GetPubKey()
pk, err := sdk.Bech32ifyAccPub(pubKey)
assert.NoError(t, err)
assert.Equal(t, "cosmospub1addwnpepqdszcr95mrqqs8lw099aa9h8h906zmet22pmwe9vquzcgvnm93eqygufdlv", pk)
assert.Equal(t, "okchainpub1addwnpepqg94y3n0sdcg5w0vhjqgp6e2ux20hxpm2sdy59nnlcny76uc729fyquy75e", pk)

// Check that restoring the key gets the same results
restoredKey, err := kb.Get("some_account")
Expand All @@ -73,11 +73,11 @@ func TestCreateLedger(t *testing.T) {
assert.Equal(t, TypeLedger, restoredKey.GetType())
pubKey = restoredKey.GetPubKey()
pk, err = sdk.Bech32ifyAccPub(pubKey)
assert.Equal(t, "cosmospub1addwnpepqdszcr95mrqqs8lw099aa9h8h906zmet22pmwe9vquzcgvnm93eqygufdlv", pk)
assert.Equal(t, "okchainpub1addwnpepqg94y3n0sdcg5w0vhjqgp6e2ux20hxpm2sdy59nnlcny76uc729fyquy75e", pk)

path, err := restoredKey.GetPath()
assert.NoError(t, err)
assert.Equal(t, "44'/118'/3'/0/1", path.String())
assert.Equal(t, "44'/996'/3'/0/1", path.String())
}

// TestKeyManagement makes sure we can manipulate these keys well
Expand All @@ -94,17 +94,17 @@ func TestKeyManagement(t *testing.T) {
require.Nil(t, err)
assert.Empty(t, l)

_, _, err = cstore.CreateMnemonic(n1, English, p1, Ed25519)
_, _, err = cstore.CreateMnemonic(n1, English, p1, Ed25519, "")
require.Error(t, err, "ed25519 keys are currently not supported by keybase")

// create some keys
_, err = cstore.Get(n1)
require.Error(t, err)
i, _, err := cstore.CreateMnemonic(n1, English, p1, algo)
i, _, err := cstore.CreateMnemonic(n1, English, p1, algo, "")

require.NoError(t, err)
require.Equal(t, n1, i.GetName())
_, _, err = cstore.CreateMnemonic(n2, English, p2, algo)
_, _, err = cstore.CreateMnemonic(n2, English, p2, algo, "")
require.NoError(t, err)

// we can get these keys
Expand All @@ -114,7 +114,7 @@ func TestKeyManagement(t *testing.T) {
require.NotNil(t, err)
_, err = cstore.GetByAddress(accAddr(i2))
require.NoError(t, err)
addr, err := sdk.AccAddressFromBech32("cosmos1yq8lgssgxlx9smjhes6ryjasmqmd3ts2559g0t")
addr, err := sdk.AccAddressFromBech32("okchain1yq8lgssgxlx9smjhes6ryjasmqmd3ts2kwlceg")
require.NoError(t, err)
_, err = cstore.GetByAddress(addr)
require.NotNil(t, err)
Expand Down Expand Up @@ -173,10 +173,10 @@ func TestSignVerify(t *testing.T) {
p1, p2, p3 := "1234", "foobar", "foobar"

// create two users and get their info
i1, _, err := cstore.CreateMnemonic(n1, English, p1, algo)
i1, _, err := cstore.CreateMnemonic(n1, English, p1, algo, "")
require.Nil(t, err)

i2, _, err := cstore.CreateMnemonic(n2, English, p2, algo)
i2, _, err := cstore.CreateMnemonic(n2, English, p2, algo, "")
require.Nil(t, err)

// Import a public key
Expand Down Expand Up @@ -251,7 +251,7 @@ func TestExportImport(t *testing.T) {
// make the storage with reasonable defaults
cstore := NewInMemory()

info, _, err := cstore.CreateMnemonic("john", English, "secretcpw", Secp256k1)
info, _, err := cstore.CreateMnemonic("john", English, "secretcpw", Secp256k1, "")
require.NoError(t, err)
require.Equal(t, info.GetName(), "john")

Expand Down Expand Up @@ -281,7 +281,7 @@ func TestExportImportPubKey(t *testing.T) {

// CreateMnemonic a private-public key pair and ensure consistency
notPasswd := "n9y25ah7"
info, _, err := cstore.CreateMnemonic("john", English, notPasswd, Secp256k1)
info, _, err := cstore.CreateMnemonic("john", English, notPasswd, Secp256k1, "")
require.Nil(t, err)
require.NotEqual(t, info, "")
require.Equal(t, info.GetName(), "john")
Expand Down Expand Up @@ -323,7 +323,7 @@ func TestAdvancedKeyManagement(t *testing.T) {
p1, p2 := "1234", "foobar"

// make sure key works with initial password
_, _, err := cstore.CreateMnemonic(n1, English, p1, algo)
_, _, err := cstore.CreateMnemonic(n1, English, p1, algo, "")
require.Nil(t, err, "%+v", err)
assertPassword(t, cstore, n1, p1, p2)

Expand Down Expand Up @@ -371,7 +371,7 @@ func TestSeedPhrase(t *testing.T) {
p1, p2 := "1234", "foobar"

// make sure key works with initial password
info, mnemonic, err := cstore.CreateMnemonic(n1, English, p1, algo)
info, mnemonic, err := cstore.CreateMnemonic(n1, English, p1, algo, "")
require.Nil(t, err, "%+v", err)
require.Equal(t, n1, info.GetName())
assert.NotEmpty(t, mnemonic)
Expand All @@ -398,16 +398,16 @@ func ExampleNew() {
sec := Secp256k1

// Add keys and see they return in alphabetical order
bob, _, err := cstore.CreateMnemonic("Bob", English, "friend", sec)
bob, _, err := cstore.CreateMnemonic("Bob", English, "friend", sec, "")
if err != nil {
// this should never happen
fmt.Println(err)
} else {
// return info here just like in List
fmt.Println(bob.GetName())
}
_, _, _ = cstore.CreateMnemonic("Alice", English, "secret", sec)
_, _, _ = cstore.CreateMnemonic("Carl", English, "mitm", sec)
_, _, _ = cstore.CreateMnemonic("Alice", English, "secret", sec, "")
_, _, _ = cstore.CreateMnemonic("Carl", English, "mitm", sec, "")
info, _ := cstore.List()
for _, i := range info {
fmt.Println(i.GetName())
Expand Down
Loading