github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/tests/bats/rollback.bats (about) 1 #!/usr/bin/env bats 2 3 : ${GETH_CMD:=$GOPATH/bin/geth} 4 5 setup() { 6 DATA_DIR=`mktemp -d` 7 cp -a $BATS_TEST_DIRNAME/../../cmd/geth/testdata/testdatadir/. $DATA_DIR/ 8 } 9 10 teardown() { 11 rm -fr $DATA_DIR 12 } 13 14 @test "rollback 42 | sets head from 384 -> 42" { 15 run $GETH_CMD --datadir $DATA_DIR rollback 42 16 echo "$output" 17 [ "$status" -eq 0 ] 18 [[ "$output" == *"Local head full block"* ]] # original head 19 [[ "$output" == *"384"* ]] # original head 20 [[ "$output" == *"Success. Head block set to: 42"* ]] 21 22 23 # Check that 'latest' block is 42. 24 run $GETH_CMD --datadir $DATA_DIR --maxpeers 0 --nodiscover --nat none --ipcdisable --exec="eth.getBlock('latest').number" console 25 echo "$output" 26 [ "$status" -eq 0 ] 27 [[ "$output" == *"42"* ]] 28 } 29 30 @test "rollback <noarg> | fails" { 31 run $GETH_CMD --datadir $DATA_DIR rollback 32 echo "$output" 33 [ "$status" -gt 0 ] 34 [[ "$output" == *'missing argument: use `rollback 12345` to specify required block number to roll back to'* ]] # original head 35 } 36 37 @test "rollback 420 | fails (420 > 384; block not yet in database)" { 38 run $GETH_CMD --datadir $DATA_DIR rollback 420 39 echo "$output" 40 [ "$status" -gt 0 ] 41 [[ "$output" == *'ERROR: Wanted rollback to set head to: 420, instead current head is: 384'* ]] # original head 42 }