remove deprecated 'tests/' directory & old D-file
This commit is contained in:
parent
3baea45694
commit
b51d5dda8c
|
@ -1,14 +0,0 @@
|
|||
FROM golang:latest
|
||||
|
||||
RUN apt-get update && apt-get install -y jq
|
||||
|
||||
RUN mkdir -p /go/src/github.com/tendermint/basecoin
|
||||
WORKDIR /go/src/github.com/tendermint/basecoin
|
||||
|
||||
COPY Makefile /go/src/github.com/tendermint/basecoin/
|
||||
COPY glide.yaml /go/src/github.com/tendermint/basecoin/
|
||||
COPY glide.lock /go/src/github.com/tendermint/basecoin/
|
||||
|
||||
RUN make get_vendor_deps
|
||||
|
||||
COPY . /go/src/github.com/tendermint/basecoin
|
6
Makefile
6
Makefile
|
@ -70,12 +70,6 @@ test_unit:
|
|||
test_cover:
|
||||
@bash test_cover.sh
|
||||
|
||||
test_tutorial:
|
||||
@shelldown ${TUTORIALS}
|
||||
@for script in docs/guide/*.sh ; do \
|
||||
bash $$script ; \
|
||||
done
|
||||
|
||||
benchmark:
|
||||
@go test -bench=. $(PACKAGES)
|
||||
|
||||
|
|
|
@ -1,260 +0,0 @@
|
|||
# This is not executable, but helper functions for the other scripts
|
||||
|
||||
# XXX XXX XXX XXX XXX
|
||||
# The following global variables must be defined before calling common functions:
|
||||
# SERVER_EXE=foobar # Server binary name
|
||||
# CLIENT_EXE=foobarcli # Client binary name
|
||||
# ACCOUNTS=(foo bar) # List of accounts for initialization
|
||||
# RICH=${ACCOUNTS[0]} # Account to assign genesis balance
|
||||
|
||||
|
||||
# XXX Ex Usage: quickSetup $WORK_NAME $CHAIN_ID
|
||||
# Desc: Start the program, use with shunit2 OneTimeSetUp()
|
||||
quickSetup() {
|
||||
# These are passed in as args
|
||||
BASE_DIR=$HOME/$1
|
||||
CHAIN_ID=$2
|
||||
|
||||
rm -rf $BASE_DIR 2>/dev/null
|
||||
mkdir -p $BASE_DIR
|
||||
|
||||
# Set up client - make sure you use the proper prefix if you set
|
||||
# a custom CLIENT_EXE
|
||||
export BC_HOME=${BASE_DIR}/client
|
||||
prepareClient
|
||||
|
||||
# start basecoin server (with counter)
|
||||
initServer $BASE_DIR $CHAIN_ID
|
||||
if [ $? != 0 ]; then return 1; fi
|
||||
|
||||
initClient $CHAIN_ID
|
||||
if [ $? != 0 ]; then return 1; fi
|
||||
|
||||
printf "...Testing may begin!\n\n\n"
|
||||
}
|
||||
|
||||
# XXX Ex Usage: quickTearDown
|
||||
# Desc: close the test server, use with shunit2 OneTimeTearDown()
|
||||
quickTearDown() {
|
||||
printf "\n\nstopping $SERVER_EXE test server..."
|
||||
kill -9 $PID_SERVER >/dev/null 2>&1
|
||||
sleep 1
|
||||
}
|
||||
|
||||
############################################################
|
||||
|
||||
prepareClient() {
|
||||
echo "Preparing client keys..."
|
||||
${CLIENT_EXE} reset_all
|
||||
assertTrue "line=${LINENO}, prepare client" $?
|
||||
|
||||
for i in "${!ACCOUNTS[@]}"; do
|
||||
newKey ${ACCOUNTS[$i]}
|
||||
done
|
||||
}
|
||||
|
||||
# XXX Ex Usage1: initServer $ROOTDIR $CHAINID
|
||||
# XXX Ex Usage2: initServer $ROOTDIR $CHAINID $PORTPREFIX
|
||||
# Desc: Grabs the Rich account and gives it all genesis money
|
||||
# port-prefix default is 4665{6,7,8}
|
||||
initServer() {
|
||||
echo "Setting up genesis..."
|
||||
SERVE_DIR=$1/server
|
||||
assertNotNull "line=${LINENO}, no chain" $2
|
||||
CHAIN=$2
|
||||
SERVER_LOG=$1/${SERVER_EXE}.log
|
||||
|
||||
GENKEY=$(${CLIENT_EXE} keys get ${RICH} | awk '{print $2}')
|
||||
${SERVER_EXE} init --static --chain-id $CHAIN $GENKEY --home=$SERVE_DIR >>$SERVER_LOG
|
||||
|
||||
# optionally set the port
|
||||
if [ -n "$3" ]; then
|
||||
echo "setting port $3"
|
||||
sed -ie "s/4665/$3/" $SERVE_DIR/config.toml
|
||||
fi
|
||||
|
||||
echo "Starting ${SERVER_EXE} server..."
|
||||
startServer $SERVE_DIR $SERVER_LOG
|
||||
return $?
|
||||
}
|
||||
|
||||
# XXX Ex Usage: startServer $SERVE_DIR $SERVER_LOG
|
||||
startServer() {
|
||||
${SERVER_EXE} start --home=$1 >>$2 2>&1 &
|
||||
sleep 5
|
||||
PID_SERVER=$!
|
||||
disown
|
||||
if ! ps $PID_SERVER >/dev/null; then
|
||||
echo "**FAILED**"
|
||||
cat $SERVER_LOG
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# XXX Ex Usage1: initClient $CHAINID
|
||||
# XXX Ex Usage2: initClient $CHAINID $PORTPREFIX
|
||||
# Desc: Initialize the client program
|
||||
# port-prefix default is 46657
|
||||
initClient() {
|
||||
echo "Attaching ${CLIENT_EXE} client..."
|
||||
PORT=${2:-46657}
|
||||
# hard-code the expected validator hash
|
||||
${CLIENT_EXE} init --chain-id=$1 --node=tcp://localhost:${PORT} --valhash=EB168E17E45BAEB194D4C79067FFECF345C64DE6
|
||||
assertTrue "line=${LINENO}, initialized light-client" $?
|
||||
}
|
||||
|
||||
# XXX Ex Usage1: newKey $NAME
|
||||
# XXX Ex Usage2: newKey $NAME $PASSWORD
|
||||
# Desc: Generates key for given username and password
|
||||
newKey(){
|
||||
assertNotNull "line=${LINENO}, keyname required" "$1"
|
||||
KEYPASS=${2:-qwertyuiop}
|
||||
(echo $KEYPASS; echo $KEYPASS) | ${CLIENT_EXE} keys new $1 >/dev/null 2>/dev/null
|
||||
assertTrue "line=${LINENO}, created $1" $?
|
||||
assertTrue "line=${LINENO}, $1 doesn't exist" "${CLIENT_EXE} keys get $1"
|
||||
}
|
||||
|
||||
# XXX Ex Usage: getAddr $NAME
|
||||
# Desc: Gets the address for a key name
|
||||
getAddr() {
|
||||
assertNotNull "line=${LINENO}, keyname required" "$1"
|
||||
RAW=$(${CLIENT_EXE} keys get $1)
|
||||
assertTrue "line=${LINENO}, no key for $1" $?
|
||||
# print the addr
|
||||
echo $RAW | cut -d' ' -f2
|
||||
}
|
||||
|
||||
# XXX Ex Usage: checkAccount $ADDR $AMOUNT [$HEIGHT]
|
||||
# Desc: Assumes just one coin, checks the balance of first coin in any case
|
||||
# pass optional height to query which block to query
|
||||
checkAccount() {
|
||||
# default height of 0, but accept an argument
|
||||
HEIGHT=${3:-0}
|
||||
|
||||
# make sure sender goes down
|
||||
ACCT=$(${CLIENT_EXE} query account $1 --height=$HEIGHT)
|
||||
if ! assertTrue "line=${LINENO}, account must exist" $?; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -n "$DEBUG" ]; then echo $ACCT; echo; fi
|
||||
assertEquals "line=${LINENO}, proper money" "$2" $(echo $ACCT | jq .data.coins[0].amount)
|
||||
return $?
|
||||
}
|
||||
|
||||
# XXX Ex Usage: checkRole $ROLE $SIGS $NUM_SIGNERS [$HEIGHT]
|
||||
# Desc: Ensures this named role exists, and has the number of members and required signatures as above
|
||||
checkRole() {
|
||||
# default height of 0, but accept an argument
|
||||
HEIGHT=${4:-0}
|
||||
|
||||
# make sure sender goes down
|
||||
QROLE=$(${CLIENT_EXE} query role $1 --height=$HEIGHT)
|
||||
if ! assertTrue "line=${LINENO}, role must exist" $?; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ -n "$DEBUG" ]; then echo $QROLE; echo; fi
|
||||
assertEquals "line=${LINENO}, proper sigs" "$2" $(echo $QROLE | jq .data.min_sigs)
|
||||
assertEquals "line=${LINENO}, proper app" '"sigs"' $(echo $QROLE | jq '.data.signers[0].app' )
|
||||
assertEquals "line=${LINENO}, proper signers" "$3" $(echo $QROLE | jq '.data.signers | length')
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
# XXX Ex Usage: txSucceeded $? "$TX" "$RECIEVER"
|
||||
# Desc: Must be called right after the `tx` command, makes sure it got a success response
|
||||
txSucceeded() {
|
||||
if (assertTrue "line=${LINENO}, sent tx ($3): $2" $1); then
|
||||
TX=$2
|
||||
assertEquals "line=${LINENO}, good check ($3): $TX" "0" $(echo $TX | jq .check_tx.code)
|
||||
assertEquals "line=${LINENO}, good deliver ($3): $TX" "0" $(echo $TX | jq .deliver_tx.code)
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# XXX Ex Usage: checkSendTx $HASH $HEIGHT $SENDER $AMOUNT
|
||||
# Desc: This looks up the tx by hash, and makes sure the height and type match
|
||||
# and that the first input was from this sender for this amount
|
||||
checkSendTx() {
|
||||
TX=$(${CLIENT_EXE} query tx $1)
|
||||
assertTrue "line=${LINENO}, found tx" $?
|
||||
if [ -n "$DEBUG" ]; then echo $TX; echo; fi
|
||||
|
||||
assertEquals "line=${LINENO}, proper height" $2 $(echo $TX | jq .height)
|
||||
assertEquals "line=${LINENO}, type=sigs/one" '"sigs/one"' $(echo $TX | jq .data.type)
|
||||
CTX=$(echo $TX | jq .data.data.tx)
|
||||
assertEquals "line=${LINENO}, type=chain/tx" '"chain/tx"' $(echo $CTX | jq .type)
|
||||
NTX=$(echo $CTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=nonce" '"nonce"' $(echo $NTX | jq .type)
|
||||
STX=$(echo $NTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=coin/send" '"coin/send"' $(echo $STX | jq .type)
|
||||
assertEquals "line=${LINENO}, proper sender" "\"$3\"" $(echo $STX | jq .data.inputs[0].address.addr)
|
||||
assertEquals "line=${LINENO}, proper out amount" "$4" $(echo $STX | jq .data.outputs[0].coins[0].amount)
|
||||
return $?
|
||||
}
|
||||
|
||||
# XXX Ex Usage: checkRoleTx $HASH $HEIGHT $NAME $NUM_SIGNERS
|
||||
# Desc: This looks up the tx by hash, and makes sure the height and type match
|
||||
# and that the it refers to the proper role
|
||||
checkRoleTx() {
|
||||
TX=$(${CLIENT_EXE} query tx $1)
|
||||
assertTrue "line=${LINENO}, found tx" $?
|
||||
if [ -n "$DEBUG" ]; then echo $TX; echo; fi
|
||||
|
||||
|
||||
assertEquals "line=${LINENO}, proper height" $2 $(echo $TX | jq .height)
|
||||
assertEquals "line=${LINENO}, type=sigs/one" '"sigs/one"' $(echo $TX | jq .data.type)
|
||||
CTX=$(echo $TX | jq .data.data.tx)
|
||||
assertEquals "line=${LINENO}, type=chain/tx" '"chain/tx"' $(echo $CTX | jq .type)
|
||||
NTX=$(echo $CTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=nonce" '"nonce"' $(echo $NTX | jq .type)
|
||||
RTX=$(echo $NTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=role/create" '"role/create"' $(echo $RTX | jq .type)
|
||||
assertEquals "line=${LINENO}, proper name" "\"$3\"" $(echo $RTX | jq .data.role)
|
||||
assertEquals "line=${LINENO}, proper num signers" "$4" $(echo $RTX | jq '.data.signers | length')
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
# XXX Ex Usage: checkSendFeeTx $HASH $HEIGHT $SENDER $AMOUNT $FEE
|
||||
# Desc: This is like checkSendTx, but asserts a feetx wrapper with $FEE value.
|
||||
# This looks up the tx by hash, and makes sure the height and type match
|
||||
# and that the first input was from this sender for this amount
|
||||
checkSendFeeTx() {
|
||||
TX=$(${CLIENT_EXE} query tx $1)
|
||||
assertTrue "line=${LINENO}, found tx" $?
|
||||
if [ -n "$DEBUG" ]; then echo $TX; echo; fi
|
||||
|
||||
assertEquals "line=${LINENO}, proper height" $2 $(echo $TX | jq .height)
|
||||
assertEquals "line=${LINENO}, type=sigs/one" '"sigs/one"' $(echo $TX | jq .data.type)
|
||||
CTX=$(echo $TX | jq .data.data.tx)
|
||||
assertEquals "line=${LINENO}, type=chain/tx" '"chain/tx"' $(echo $CTX | jq .type)
|
||||
NTX=$(echo $CTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=nonce" '"nonce"' $(echo $NTX | jq .type)
|
||||
FTX=$(echo $NTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=fee/tx" '"fee/tx"' $(echo $FTX | jq .type)
|
||||
assertEquals "line=${LINENO}, proper fee" "$5" $(echo $FTX | jq .data.fee.amount)
|
||||
STX=$(echo $FTX | jq .data.tx)
|
||||
assertEquals "line=${LINENO}, type=coin/send" '"coin/send"' $(echo $STX | jq .type)
|
||||
assertEquals "line=${LINENO}, proper sender" "\"$3\"" $(echo $STX | jq .data.inputs[0].address.addr)
|
||||
assertEquals "line=${LINENO}, proper out amount" "$4" $(echo $STX | jq .data.outputs[0].coins[0].amount)
|
||||
return $?
|
||||
}
|
||||
|
||||
|
||||
# XXX Ex Usage: waitForBlock $port
|
||||
# Desc: Waits until the block height on that node increases by one
|
||||
waitForBlock() {
|
||||
addr=http://localhost:$1
|
||||
b1=`curl -s $addr/status | jq .result.latest_block_height`
|
||||
b2=$b1
|
||||
while [ "$b2" == "$b1" ]; do
|
||||
echo "Waiting for node $addr to commit a block ..."
|
||||
sleep 1
|
||||
b2=`curl -s $addr/status | jq .result.latest_block_height`
|
||||
done
|
||||
}
|
||||
|
||||
|
1067
tests/cli/shunit2
1067
tests/cli/shunit2
File diff suppressed because it is too large
Load Diff
|
@ -1,142 +0,0 @@
|
|||
package main
|
||||
|
||||
func main() {}
|
||||
|
||||
// import (
|
||||
// "fmt"
|
||||
// "time"
|
||||
|
||||
// "github.com/gorilla/websocket"
|
||||
// "github.com/cosmos/cosmos-sdk/types"
|
||||
// wire "github.com/tendermint/go-wire"
|
||||
// _ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
|
||||
// "github.com/tendermint/tendermint/rpc/lib/client"
|
||||
// "github.com/tendermint/tendermint/rpc/lib/types"
|
||||
// cmn "github.com/tendermint/tmlibs/common"
|
||||
// )
|
||||
|
||||
// func main() {
|
||||
// // ws := rpcclient.NewWSClient("127.0.0.1:46657", "/websocket")
|
||||
// ws := rpcclient.NewWSClient("192.168.99.100:46657", "/websocket")
|
||||
// chainID := "test_chain_id"
|
||||
|
||||
// _, err := ws.Start()
|
||||
// if err != nil {
|
||||
// cmn.Exit(err.Error())
|
||||
// }
|
||||
// var counter = 0
|
||||
|
||||
// // Read a bunch of responses
|
||||
// go func() {
|
||||
// for {
|
||||
// res, ok := <-ws.ResultsCh
|
||||
// if !ok {
|
||||
// break
|
||||
// }
|
||||
// fmt.Println(counter, "res:", cmn.Blue(string(res)))
|
||||
// }
|
||||
// }()
|
||||
|
||||
// // Get the root account
|
||||
// root := types.PrivAccountFromSecret("test")
|
||||
// sequence := int(0)
|
||||
// // Make a bunch of PrivAccounts
|
||||
// privAccounts := types.RandAccounts(1000, 1000000, 0)
|
||||
// privAccountSequences := make(map[string]int)
|
||||
|
||||
// // Send coins to each account
|
||||
// for i := 0; i < len(privAccounts); i++ {
|
||||
// privAccount := privAccounts[i]
|
||||
// tx := &types.SendTx{
|
||||
// Inputs: []types.TxInput{
|
||||
// types.TxInput{
|
||||
// Address: root.Account.PubKey.Address(),
|
||||
// PubKey: root.Account.PubKey, // TODO is this needed?
|
||||
// Coins: coin.Coins{{"", 1000002}},
|
||||
// Sequence: sequence,
|
||||
// },
|
||||
// },
|
||||
// Outputs: []types.TxOutput{
|
||||
// types.TxOutput{
|
||||
// Address: privAccount.Account.PubKey.Address(),
|
||||
// Coins: coin.Coins{{"", 1000000}},
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
// sequence += 1
|
||||
|
||||
// // Sign request
|
||||
// signBytes := tx.SignBytes(chainID)
|
||||
// sig := root.Sign(signBytes)
|
||||
// tx.Inputs[0].Signature = sig
|
||||
// //fmt.Println("tx:", tx)
|
||||
|
||||
// // Write request
|
||||
// txBytes := wire.BinaryBytes(struct{ types.Tx }{tx})
|
||||
// request, err := rpctypes.MapToRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes})
|
||||
// if err != nil {
|
||||
// cmn.Exit("cannot encode request: " + err.Error())
|
||||
// }
|
||||
// reqBytes := wire.JSONBytes(request)
|
||||
// //fmt.Print(".")
|
||||
// err = ws.WriteMessage(websocket.TextMessage, reqBytes)
|
||||
// if err != nil {
|
||||
// cmn.Exit("writing websocket request: " + err.Error())
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Now send coins between these accounts
|
||||
// for {
|
||||
// counter += 1
|
||||
// time.Sleep(time.Millisecond * 10)
|
||||
|
||||
// randA := cmn.RandInt() % len(privAccounts)
|
||||
// randB := cmn.RandInt() % len(privAccounts)
|
||||
// if randA == randB {
|
||||
// continue
|
||||
// }
|
||||
|
||||
// privAccountA := privAccounts[randA]
|
||||
// privAccountASequence := privAccountSequences[privAccountA.Account.PubKey.KeyString()]
|
||||
// privAccountSequences[privAccountA.Account.PubKey.KeyString()] = privAccountASequence + 1
|
||||
// privAccountB := privAccounts[randB]
|
||||
|
||||
// tx := &types.SendTx{
|
||||
// Inputs: []types.TxInput{
|
||||
// types.TxInput{
|
||||
// Address: privAccountA.Account.PubKey.Address(),
|
||||
// PubKey: privAccountA.Account.PubKey,
|
||||
// Coins: coin.Coins{{"", 3}},
|
||||
// Sequence: privAccountASequence + 1,
|
||||
// },
|
||||
// },
|
||||
// Outputs: []types.TxOutput{
|
||||
// types.TxOutput{
|
||||
// Address: privAccountB.Account.PubKey.Address(),
|
||||
// Coins: coin.Coins{{"", 1}},
|
||||
// },
|
||||
// },
|
||||
// }
|
||||
|
||||
// // Sign request
|
||||
// signBytes := tx.SignBytes(chainID)
|
||||
// sig := privAccountA.Sign(signBytes)
|
||||
// tx.Inputs[0].Signature = sig
|
||||
// //fmt.Println("tx:", tx)
|
||||
|
||||
// // Write request
|
||||
// txBytes := wire.BinaryBytes(struct{ types.Tx }{tx})
|
||||
// request, err := rpctypes.MapToRequest("fakeid", "broadcast_tx_sync", map[string]interface{}{"tx": txBytes})
|
||||
// if err != nil {
|
||||
// cmn.Exit("cannot encode request: " + err.Error())
|
||||
// }
|
||||
// reqBytes := wire.JSONBytes(request)
|
||||
// //fmt.Print(".")
|
||||
// err = ws.WriteMessage(websocket.TextMessage, reqBytes)
|
||||
// if err != nil {
|
||||
// cmn.Exit("writing websocket request: " + err.Error())
|
||||
// }
|
||||
// }
|
||||
|
||||
// ws.Stop()
|
||||
// }
|
Loading…
Reference in New Issue