Skip to content

Commit a44459e

Browse files
authored
cleanup code (#386)
1 parent cd0ee2a commit a44459e

File tree

10 files changed

+83
-7
lines changed

10 files changed

+83
-7
lines changed

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ linters-settings:
6666
# Available rules: https://github.com/securego/gosec#available-rules
6767
# Default: [] - means include all rules
6868
includes:
69-
# - G101 # Look for hard coded credentials
7069
- G102 # Bind to all interfaces
7170
- G103 # Audit the use of unsafe block
7271
- G104 # Audit errors not checked

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
33
COMMIT := $(shell git log -1 --format='%H')
44
LEDGER_ENABLED ?= true
55
BINDIR ?= $(GOPATH)/bin
6+
MOCKS_DIR = $(CURDIR)/tests/mocks
67
APP = ./app
78

89
DOCKER := $(shell which docker)
@@ -59,6 +60,10 @@ release: go.sum
5960
env GOOS=windows GOARCH=amd64 \
6061
go build -mod=readonly -o ./build/yoda_windows_amd64 $(BUILD_FLAGS) ./cmd/yoda
6162

63+
mocks:
64+
@go install go.uber.org/mock/mockgen@latest
65+
sh ./scripts/mockgen.sh
66+
6267
go.sum: go.mod
6368
@echo "--> Ensure dependencies have not been modified"
6469
GO111MODULE=on go mod verify
@@ -115,5 +120,5 @@ test-sim-deterministic: runsim
115120
@echo "Running application deterministic simulation. This may take awhile!"
116121
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism
117122

118-
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking \
123+
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking mocks \
119124
test-sim-import-export test-sim-multi-seed-short test-sim-after-import test-sim-deterministic

benchmark/app_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func InitializeBenchmarkApp(tb testing.TB, maxGasPerBlock int64) *BenchmarkApp {
4343
},
4444
TB: tb,
4545
}
46-
ba.Ctx = ba.NewUncachedContext(false, tmproto.Header{})
46+
ba.Ctx = ba.NewUncachedContext(false, tmproto.Header{ChainID: bandtesting.ChainID})
4747
ba.Querier = keeper.Querier{
4848
Keeper: ba.OracleKeeper,
4949
}
@@ -91,8 +91,11 @@ func (ba *BenchmarkApp) DeliverMsg(account *Account, msgs []sdk.Msg) (sdk.GasInf
9191
func (ba *BenchmarkApp) CallBeginBlock() abci.ResponseBeginBlock {
9292
return ba.BeginBlock(
9393
abci.RequestBeginBlock{
94-
Header: tmproto.Header{Height: ba.LastBlockHeight() + 1},
95-
Hash: ba.LastCommitID().Hash,
94+
Header: tmproto.Header{
95+
Height: ba.LastBlockHeight() + 1,
96+
ChainID: bandtesting.ChainID,
97+
},
98+
Hash: ba.LastCommitID().Hash,
9699
},
97100
)
98101
}

benchmark/helper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func GenSequenceOfTxs(
133133
msgs,
134134
sdk.Coins{sdk.NewInt64Coin("uband", 1)},
135135
math.MaxInt64,
136-
"",
136+
bandtesting.ChainID,
137137
[]uint64{account.Num},
138138
[]uint64{account.Seq},
139139
account.PrivKey,

scripts/generate_genesis.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ echo "lock nasty suffer dirt dream fine fall deal curtain plate husband sound to
88
| bandd keys add validator --recover --keyring-backend test
99
echo "smile stem oven genius cave resource better lunar nasty moon company ridge brass rather supply used horn three panic put venue analyst leader comic" \
1010
| bandd keys add requester --recover --keyring-backend test
11-
11+
echo "erase relief tree tobacco around knee concert toast diesel melody rule sight forum camera oil sick leopard valid furnace casino post dumb tag young" \
12+
| bandd keys add account1 --recover --keyring-backend test
13+
echo "thought insane behind cool expand clarify strategy occur arrive broccoli middle despair foot cake genuine dawn goose abuse curve identify dinner derive genre effort" \
14+
| bandd keys add account2 --recover --keyring-backend test
1215

1316
# add accounts to genesis
1417
bandd genesis add-genesis-account validator 10000000000000uband --keyring-backend test
1518
bandd genesis add-genesis-account requester 10000000000000uband --keyring-backend test
19+
bandd genesis add-genesis-account account1 10000000000000uband --keyring-backend test
20+
bandd genesis add-genesis-account account2 10000000000000uband --keyring-backend test
1621

1722

1823
# register initial validators
@@ -34,3 +39,6 @@ sed -i -e \
3439
sed -i -e \
3540
'/\[mempool\]/,+10 s/version = .*/version = \"v1\"/' \
3641
~/.band/config/config.toml
42+
43+
# update voting period to be 60s for testing
44+
cat <<< $(jq '.app_state.gov.params.voting_period = "60s"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json

scripts/group/create_group.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
export WALLET_NAME=account1
4+
export ENDPOINT=http://localhost:26657
5+
6+
BASEDIR=$(dirname "$0")
7+
8+
TX_HASH=$(bandd tx group create-group $(bandd keys show $WALLET_NAME --address --keyring-backend test) "ipfs://" $BASEDIR/group_members.json \
9+
--from $WALLET_NAME \
10+
--node $ENDPOINT \
11+
-y --keyring-backend test --gas-prices 0.0025uband -b sync --output json | jq '.txhash'| tr -d '"')
12+
echo "TX_HASH: $TX_HASH"
13+
14+
sleep 3
15+
16+
GROUP_ID=$(bandd query tx $TX_HASH --node $ENDPOINT --output json | jq '.events' | jq -r '.[] | select(.type == "cosmos.group.v1.EventCreateGroup") | .attributes[0].value' | jq -r '.')
17+
echo "GROUP_ID: $GROUP_ID"
18+

scripts/group/create_policy.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
export WALLET_NAME=account1
4+
export GROUP_ID=1
5+
export ENDPOINT=http://localhost:26657
6+
7+
BASEDIR=$(dirname "$0")
8+
9+
TX_HASH=$(bandd tx group create-group-policy $(bandd keys show $WALLET_NAME --address --keyring-backend test) $GROUP_ID "{\"name\":\"policy 1\",\"description\":\"\"}" $BASEDIR/threshold_policy.json \
10+
--from $WALLET_NAME \
11+
--node $ENDPOINT \
12+
-y --keyring-backend test --gas-prices 0.0025uband -b sync --output json | jq '.txhash'| tr -d '"')
13+
echo "TX_HASH: $TX_HASH"
14+
15+
sleep 3
16+
17+
GROUP_POLICY_ADDRESS=$(bandd query tx $TX_HASH --node $ENDPOINT --output json | jq '.events' | jq -r '.[] | select(.type == "cosmos.group.v1.EventCreateGroupPolicy") | .attributes[0].value' | jq -r '.')
18+
echo "GROUP_POLICY_ADDRESS: $GROUP_POLICY_ADDRESS"

scripts/group/group_members.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"members": [
3+
{
4+
"address": "band1w8yurh6naeqg4mjx4zcs7hsu3fppwu0f4q4l7f",
5+
"weight": "1",
6+
"metadata": "account1"
7+
},
8+
{
9+
"address": "band1ph8tcg7ncxxx5vndfc9h6ffsn4st4whq3rn260",
10+
"weight": "1",
11+
"metadata": "account2"
12+
}
13+
]
14+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@type": "/cosmos.group.v1.ThresholdDecisionPolicy",
3+
"threshold": "2",
4+
"windows": {
5+
"voting_period": "1m",
6+
"min_execution_period": "0s"
7+
}
8+
}

scripts/mockgen.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
mockgen_cmd="mockgen"

0 commit comments

Comments
 (0)