diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-23 23:04:21 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-23 23:04:21 +0800 |
commit | 3f6e1b2fd3cbc6aeb1bbe658dd5b70945a57dffa (patch) | |
tree | 6da97d39c03b125d4824c570bede3fb445c756a0 /rpc/args_test.go | |
parent | dbb2af6016c952b0f49d552a10fc59af0a9f7ce7 (diff) | |
download | dexon-3f6e1b2fd3cbc6aeb1bbe658dd5b70945a57dffa.tar.gz dexon-3f6e1b2fd3cbc6aeb1bbe658dd5b70945a57dffa.tar.zst dexon-3f6e1b2fd3cbc6aeb1bbe658dd5b70945a57dffa.zip |
db_putHex/db_getHex + tests
Diffstat (limited to 'rpc/args_test.go')
-rw-r--r-- | rpc/args_test.go | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/rpc/args_test.go b/rpc/args_test.go index cfdd278b8..2ad53fba2 100644 --- a/rpc/args_test.go +++ b/rpc/args_test.go @@ -485,11 +485,11 @@ func TestBlockFilterArgsEmptyArgs(t *testing.T) { } func TestDbArgs(t *testing.T) { - input := `["0x74657374","0x6b6579","0x6d79537472696e67"]` + input := `["testDB","myKey","0xbeef"]` expected := new(DbArgs) - expected.Database = "0x74657374" - expected.Key = "0x6b6579" - expected.Value = "0x6d79537472696e67" + expected.Database = "testDB" + expected.Key = "myKey" + expected.Value = []byte("0xbeef") args := new(DbArgs) if err := json.Unmarshal([]byte(input), &args); err != nil { @@ -508,7 +508,36 @@ func TestDbArgs(t *testing.T) { t.Errorf("Key shoud be %#v but is %#v", expected.Key, args.Key) } - if expected.Value != args.Value { + if bytes.Compare(expected.Value, args.Value) != 0 { + t.Errorf("Value shoud be %#v but is %#v", expected.Value, args.Value) + } +} + +func TestDbHexArgs(t *testing.T) { + input := `["testDB","myKey","0xbeef"]` + expected := new(DbHexArgs) + expected.Database = "testDB" + expected.Key = "myKey" + expected.Value = []byte{0xbe, 0xef} + + args := new(DbHexArgs) + if err := json.Unmarshal([]byte(input), &args); err != nil { + t.Error(err) + } + + if err := args.requirements(); err != nil { + t.Error(err) + } + + if expected.Database != args.Database { + t.Errorf("Database shoud be %#v but is %#v", expected.Database, args.Database) + } + + if expected.Key != args.Key { + t.Errorf("Key shoud be %#v but is %#v", expected.Key, args.Key) + } + + if bytes.Compare(expected.Value, args.Value) != 0 { t.Errorf("Value shoud be %#v but is %#v", expected.Value, args.Value) } } |