Tested sending 1 sig from role

This commit is contained in:
Ethan Frey 2017-07-19 16:36:35 +02:00
parent 63fc25e74e
commit 5f1d98ba0f
3 changed files with 34 additions and 6 deletions

View File

@ -32,6 +32,7 @@ test_cli: tests/cli/shunit2
./tests/cli/rpc.sh
./tests/cli/init.sh
./tests/cli/basictx.sh
./tests/cli/roles.sh
./tests/cli/counter.sh
./tests/cli/restart.sh
# @./tests/cli/ibc.sh

View File

@ -145,7 +145,9 @@ func (app *Basecoin) CheckTx(txBytes []byte) abci.Result {
return errors.Result(err)
}
// TODO: can we abstract this setup and commit logic??
// we also need to discard error changes, so we don't increment checktx
// sequence on error, but not delivertx
cache := app.cacheState.CacheWrap()
ctx := stack.NewContext(
app.state.GetChainID(),
app.height,
@ -153,11 +155,12 @@ func (app *Basecoin) CheckTx(txBytes []byte) abci.Result {
)
// checktx generally shouldn't touch the state, but we don't care
// here on the framework level, since the cacheState is thrown away next block
res, err := app.handler.CheckTx(ctx, app.cacheState, tx)
res, err := app.handler.CheckTx(ctx, cache, tx)
if err != nil {
return errors.Result(err)
}
cache.CacheSync()
return res.ToABCI()
}

View File

@ -24,15 +24,17 @@ test01SetupRole() {
THREE=$(getAddr $DUDE)
MEMBERS=${ONE},${TWO},${THREE}
SIGS=1
assertFalse "line=${LINENO}, missing min-sigs" "echo qwertyuiop | ${CLIENT_EXE} tx create-role --role=bank --members=${MEMBERS} --sequence=1 --name=$RICH"
assertFalse "line=${LINENO}, missing members" "echo qwertyuiop | ${CLIENT_EXE} tx create-role --role=bank --min-sigs=2 --sequence=1 --name=$RICH"
assertFalse "line=${LINENO}, missing role" "echo qwertyuiop | ${CLIENT_EXE} tx create-role --min-sigs=2 --members=${MEMBERS} --sequence=1 --name=$RICH"
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx create-role --role=bank --min-sigs=2 --members=${MEMBERS} --sequence=1 --name=$RICH)
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx create-role --role=bank --min-sigs=$SIGS --members=${MEMBERS} --sequence=1 --name=$RICH)
txSucceeded $? "$TX" "bank"
HASH=$(echo $TX | jq .hash | tr -d \")
TX_HEIGHT=$(echo $TX | jq .height)
checkRole bank 2 3
checkRole bank $SIGS 3
# Make sure tx is indexed
checkRoleTx $HASH $TX_HEIGHT "bank" 3
@ -40,8 +42,10 @@ test01SetupRole() {
test02SendTxToRole() {
SENDER=$(getAddr $RICH)
HEXROLE=$(toHex bank)
RECV="role:$HEXROLE"
RECV=role:$(toHex bank)
# HEXROLE=$(toHex bank)
# RECV="role:$HEXROLE"
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --fee=90mycoin --amount=10000mycoin --to=$RECV --sequence=2 --name=$RICH)
txSucceeded $? "$TX" "bank"
@ -55,6 +59,26 @@ test02SendTxToRole() {
checkSendFeeTx $HASH $TX_HEIGHT $SENDER "10000" "90"
}
test03SendMultiFromRole() {
ONE=$(getAddr $RICH)
TWO=$(getAddr $POOR)
THREE=$(getAddr $DUDE)
BANK=role:$(toHex bank)
# no money to start mr. poor...
assertFalse "line=${LINENO}, has no money yet" "${CLIENT_EXE} query account $TWO 2>/dev/null"
# let's try to send money from the role directly without multisig
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=1 --name=$POOR 2>/dev/null)
assertFalse "need to assume role" $?
# echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=1 --assume-role=bank --name=$POOR --prepare=-
TX=$(echo qwertyuiop | ${CLIENT_EXE} tx send --amount=6000mycoin --from=$BANK --to=$TWO --sequence=1 --assume-role=bank --name=$POOR)
txSucceeded $? "$TX" "from-bank"
checkAccount $TWO "6000"
checkAccount $BANK "4000"
}
# test02SendTxWithFee() {
# SENDER=$(getAddr $RICH)
# RECV=$(getAddr $POOR)