github.com/ethereumproject/go-ethereum@v5.5.2+incompatible/tests/bats/api_personal.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  # Current build.
     4  : ${GETH_CMD:=$GOPATH/bin/geth}
     5  : ${GETH_OPTS:=--datadir $BATS_TMPDIR \
     6                 		--lightkdf \
     7                 		--verbosity 0 \
     8                 		--display 0 \
     9                 		--port 33333 \
    10                 		--no-discover \
    11                 		--keystore $GOPATH/src/github.com/ethereumproject/go-ethereum/accounts/testdata/keystore \
    12                 		--unlock "f466859ead1932d743d622cb74fc058882e8648a" \
    13      }
    14  
    15  setup() {
    16  	# GETH_TMP_DATA_DIR=`mktemp -d`
    17  	# mkdir "$BATS_TMPDIR/mainnet"
    18      testacc=f466859ead1932d743d622cb74fc058882e8648a
    19  	tesetacc_pass=foobar
    20  	regex_signature_success='0x[0-9a-f]{130}'
    21  }
    22  
    23  # teardown() {
    24  # }
    25  
    26  @test "personal_sign1" {
    27      run $GETH_CMD $GETH_OPTS \
    28  				--password=<(echo $tesetacc_pass) \
    29          --exec="personal.sign('0xdeadbeef', '"$testacc"', '"$tesetacc_pass"');" console 2> /dev/null
    30  		echo "$output"
    31  		[ "$status" -eq 0 ]
    32      [[ "$output" =~ $regex_signature_success ]]
    33  }
    34  
    35  @test "personal_sign2" {
    36      run $GETH_CMD $GETH_OPTS \
    37  				--password=<(echo $tesetacc_pass) \
    38          --exec="personal.sign(web3.fromAscii('Schoolbus'), '"$testacc"', '"$tesetacc_pass"');" console 2> /dev/null
    39  		echo "$output"
    40  		[ "$status" -eq 0 ]
    41      [[ "$output" =~ $regex_signature_success ]]
    42  }
    43  
    44  @test "personal_listAccounts" {
    45      run $GETH_CMD $GETH_OPTS \
    46  				--password=<(echo $tesetacc_pass) \
    47          --exec="personal.listAccounts;" console 2> /dev/null
    48  		echo "$output"
    49  		[ "$status" -eq 0 ]
    50      [[ "$output" =~ $testacc ]]
    51  }
    52  
    53  @test "personal_lockAccount" {
    54      run $GETH_CMD $GETH_OPTS \
    55  				--password=<(echo $tesetacc_pass) \
    56          --exec="personal.lockAccount('"$testacc"');" console 2> /dev/null
    57  		echo "$output"
    58  		[ "$status" -eq 0 ]
    59      [[ "$output" =~ 'true' ]]
    60  }
    61  
    62  @test "personal_unlockAccount" {
    63      run $GETH_CMD $GETH_OPTS \
    64  				--password=<(echo $tesetacc_pass) \
    65          --exec="personal.lockAccount('"$testacc"') && personal.unlockAccount('"$testacc"', '"$tesetacc_pass"', 0);" console 2> /dev/null
    66  		echo "$output"
    67  		[ "$status" -eq 0 ]
    68      [[ "$output" =~ 'true' ]]
    69  }