Skip to content

Commit

Permalink
cleanup code (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
RogerKSI committed May 21, 2024
1 parent cd0ee2a commit a44459e
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 7 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ linters-settings:
# Available rules: https://github.com/securego/gosec#available-rules
# Default: [] - means include all rules
includes:
# - G101 # Look for hard coded credentials
- G102 # Bind to all interfaces
- G103 # Audit the use of unsafe block
- G104 # Audit errors not checked
Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git log -1 --format='%H')
LEDGER_ENABLED ?= true
BINDIR ?= $(GOPATH)/bin
MOCKS_DIR = $(CURDIR)/tests/mocks
APP = ./app

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

mocks:
@go install go.uber.org/mock/mockgen@latest
sh ./scripts/mockgen.sh

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
GO111MODULE=on go mod verify
Expand Down Expand Up @@ -115,5 +120,5 @@ test-sim-deterministic: runsim
@echo "Running application deterministic simulation. This may take awhile!"
@$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(APP) -ExitOnFail 1 1 TestAppStateDeterminism

.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking \
.PHONY: proto-all proto-gen proto-swagger-gen proto-format proto-lint proto-check-breaking mocks \
test-sim-import-export test-sim-multi-seed-short test-sim-after-import test-sim-deterministic
9 changes: 6 additions & 3 deletions benchmark/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func InitializeBenchmarkApp(tb testing.TB, maxGasPerBlock int64) *BenchmarkApp {
},
TB: tb,
}
ba.Ctx = ba.NewUncachedContext(false, tmproto.Header{})
ba.Ctx = ba.NewUncachedContext(false, tmproto.Header{ChainID: bandtesting.ChainID})
ba.Querier = keeper.Querier{
Keeper: ba.OracleKeeper,
}
Expand Down Expand Up @@ -91,8 +91,11 @@ func (ba *BenchmarkApp) DeliverMsg(account *Account, msgs []sdk.Msg) (sdk.GasInf
func (ba *BenchmarkApp) CallBeginBlock() abci.ResponseBeginBlock {
return ba.BeginBlock(
abci.RequestBeginBlock{
Header: tmproto.Header{Height: ba.LastBlockHeight() + 1},
Hash: ba.LastCommitID().Hash,
Header: tmproto.Header{
Height: ba.LastBlockHeight() + 1,
ChainID: bandtesting.ChainID,
},
Hash: ba.LastCommitID().Hash,
},
)
}
Expand Down
2 changes: 1 addition & 1 deletion benchmark/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func GenSequenceOfTxs(
msgs,
sdk.Coins{sdk.NewInt64Coin("uband", 1)},
math.MaxInt64,
"",
bandtesting.ChainID,
[]uint64{account.Num},
[]uint64{account.Seq},
account.PrivKey,
Expand Down
10 changes: 9 additions & 1 deletion scripts/generate_genesis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@ echo "lock nasty suffer dirt dream fine fall deal curtain plate husband sound to
| bandd keys add validator --recover --keyring-backend test
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" \
| bandd keys add requester --recover --keyring-backend test

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" \
| bandd keys add account1 --recover --keyring-backend test
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" \
| bandd keys add account2 --recover --keyring-backend test

# add accounts to genesis
bandd genesis add-genesis-account validator 10000000000000uband --keyring-backend test
bandd genesis add-genesis-account requester 10000000000000uband --keyring-backend test
bandd genesis add-genesis-account account1 10000000000000uband --keyring-backend test
bandd genesis add-genesis-account account2 10000000000000uband --keyring-backend test


# register initial validators
Expand All @@ -34,3 +39,6 @@ sed -i -e \
sed -i -e \
'/\[mempool\]/,+10 s/version = .*/version = \"v1\"/' \
~/.band/config/config.toml

# update voting period to be 60s for testing
cat <<< $(jq '.app_state.gov.params.voting_period = "60s"' ~/.band/config/genesis.json) > ~/.band/config/genesis.json
18 changes: 18 additions & 0 deletions scripts/group/create_group.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

export WALLET_NAME=account1
export ENDPOINT=http://localhost:26657

BASEDIR=$(dirname "$0")

TX_HASH=$(bandd tx group create-group $(bandd keys show $WALLET_NAME --address --keyring-backend test) "ipfs://" $BASEDIR/group_members.json \
--from $WALLET_NAME \
--node $ENDPOINT \
-y --keyring-backend test --gas-prices 0.0025uband -b sync --output json | jq '.txhash'| tr -d '"')
echo "TX_HASH: $TX_HASH"

sleep 3

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 '.')
echo "GROUP_ID: $GROUP_ID"

18 changes: 18 additions & 0 deletions scripts/group/create_policy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

export WALLET_NAME=account1
export GROUP_ID=1
export ENDPOINT=http://localhost:26657

BASEDIR=$(dirname "$0")

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 \
--from $WALLET_NAME \
--node $ENDPOINT \
-y --keyring-backend test --gas-prices 0.0025uband -b sync --output json | jq '.txhash'| tr -d '"')
echo "TX_HASH: $TX_HASH"

sleep 3

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 '.')
echo "GROUP_POLICY_ADDRESS: $GROUP_POLICY_ADDRESS"
14 changes: 14 additions & 0 deletions scripts/group/group_members.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"members": [
{
"address": "band1w8yurh6naeqg4mjx4zcs7hsu3fppwu0f4q4l7f",
"weight": "1",
"metadata": "account1"
},
{
"address": "band1ph8tcg7ncxxx5vndfc9h6ffsn4st4whq3rn260",
"weight": "1",
"metadata": "account2"
}
]
}
8 changes: 8 additions & 0 deletions scripts/group/threshold_policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"@type": "/cosmos.group.v1.ThresholdDecisionPolicy",
"threshold": "2",
"windows": {
"voting_period": "1m",
"min_execution_period": "0s"
}
}
3 changes: 3 additions & 0 deletions scripts/mockgen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

mockgen_cmd="mockgen"

0 comments on commit a44459e

Please sign in to comment.