Skip to content

Commit

Permalink
Merge pull request #11 from cypherhat/master
Browse files Browse the repository at this point in the history
balance by address testing
  • Loading branch information
cypherhat authored Aug 25, 2018
2 parents 5c36c60 + 14173ac commit fe73b3f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
4 changes: 2 additions & 2 deletions path_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ func addressesPaths(b *EthereumBackend) []*framework.Path {
},
},
&framework.Path{
Pattern: "addresses/" + framework.GenericNameRegex("name") + "/balance",
Pattern: "addresses/" + framework.GenericNameRegex("address") + "/balance",
HelpSynopsis: "Retrieve this accounts balance.",
HelpDescription: `
Retrieve this accounts balance.
`,
Fields: map[string]*framework.FieldSchema{
"name": &framework.FieldSchema{Type: framework.TypeString},
"address": &framework.FieldSchema{Type: framework.TypeString},
},
ExistenceCheck: b.pathExistenceCheck,
Callbacks: map[logical.Operation]framework.OperationFunc{
Expand Down
19 changes: 15 additions & 4 deletions test/ethereum/config/config.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats

@test "test write config" {
config="$(vault write -format=json -f ethereum/config | jq .data)"
@test "test write rinkeby config" {
config="$(vault write -format=json ethereum/rinkeby/config @rinkeby.json | jq .data)"
api_key="$(echo $config | jq -r .api_key)"
bound_cidr_list="$(echo $config | jq -r .bound_cidr_list)"
chain_id="$(echo $config | jq -r .chain_id)"
Expand All @@ -11,13 +11,24 @@
[ "$rpc_url" = "https://rinkeby.infura.io" ]
}

@test "test write mainnet config" {
config="$(vault write -format=json ethereum/mainnet/config @mainnet.json | jq .data)"
api_key="$(echo $config | jq -r .api_key)"
bound_cidr_list="$(echo $config | jq -r .bound_cidr_list)"
chain_id="$(echo $config | jq -r .chain_id)"
rpc_url="$(echo $config | jq -r .rpc_url)"
[ "$api_key" = "" ]
[ "$chain_id" = "1" ]
[ "$rpc_url" = "https://mainnet.infura.io" ]
}

@test "test read config" {
config="$(vault write -format=json -f ethereum/config | jq .data)"
config="$(vault write -format=json ethereum/mainnet/config @mainnet.json | jq .data)"
api_key="$(echo $config | jq -r .api_key)"
bound_cidr_list="$(echo $config | jq -r .bound_cidr_list)"
chain_id="$(echo $config | jq -r .chain_id)"
rpc_url="$(echo $config | jq -r .rpc_url)"
read_config="$(vault read -format=json ethereum/config | jq .data)"
read_config="$(vault read -format=json ethereum/mainnet/config | jq .data)"
read_api_key="$(echo $read_config | jq -r .api_key)"
read_bound_cidr_list="$(echo $read_config | jq -r .bound_cidr_list)"
read_chain_id="$(echo $read_config | jq -r .chain_id)"
Expand Down
4 changes: 4 additions & 0 deletions test/ethereum/config/mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"rpc_url": "https://mainnet.infura.io",
"chain_id": "1"
}
4 changes: 4 additions & 0 deletions test/ethereum/config/rinkeby.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"rpc_url": "https://rinkeby.infura.io",
"chain_id": "4"
}

0 comments on commit fe73b3f

Please sign in to comment.