From 5df322459c9d981243dd3cb1325afbc46c46140a Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Sun, 12 Jan 2020 20:39:13 +0100 Subject: [PATCH 1/2] go/runtime/client: Return empty sequences instead of nil --- .changelog/2542.bugfix.md | 4 ++++ go/runtime/client/client.go | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changelog/2542.bugfix.md diff --git a/.changelog/2542.bugfix.md b/.changelog/2542.bugfix.md new file mode 100644 index 00000000000..9bd0939f5f7 --- /dev/null +++ b/.changelog/2542.bugfix.md @@ -0,0 +1,4 @@ +go/runtime/client: Return empty sequences instead of nil. + +The runtime client endpoint should return empty sequences instead of `nil` as serde doesn't know how +to decode a `NULL` when the expected type is a sequence. diff --git a/go/runtime/client/client.go b/go/runtime/client/client.go index 4c0fdaadddf..1abe3c972c9 100644 --- a/go/runtime/client/client.go +++ b/go/runtime/client/client.go @@ -326,7 +326,7 @@ func (c *runtimeClient) GetTxs(ctx context.Context, request *api.GetTxsRequest) return nil, err } - var inputs [][]byte + inputs := [][]byte{} for _, tx := range txs { inputs = append(inputs, tx.Input) } @@ -391,7 +391,7 @@ func (c *runtimeClient) QueryTxs(ctx context.Context, request *api.QueryTxsReque return nil, err } - var output []*api.TxResult + output := []*api.TxResult{} for round, txResults := range results { // Fetch block for the given round. var blk *block.Block From 71e63eca21e1d53f23b7b4a91a961b0e58050277 Mon Sep 17 00:00:00 2001 From: Jernej Kos Date: Sun, 12 Jan 2020 20:39:38 +0100 Subject: [PATCH 2/2] tests/clients/simple-keyvalue: Query up to latest round --- tests/clients/simple-keyvalue/src/main.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/clients/simple-keyvalue/src/main.rs b/tests/clients/simple-keyvalue/src/main.rs index f8423173065..d698cac95b6 100644 --- a/tests/clients/simple-keyvalue/src/main.rs +++ b/tests/clients/simple-keyvalue/src/main.rs @@ -150,12 +150,9 @@ fn main() { // Test wait_block_indexed call. println!("Waiting for block to be indexed..."); - rt.block_on( - kv_client - .txn_client() - .wait_block_indexed(latest_snapshot.block.header.round), - ) - .expect("wait block indexed"); + let latest_round = latest_snapshot.block.header.round; + rt.block_on(kv_client.txn_client().wait_block_indexed(latest_round)) + .expect("wait block indexed"); // Test get_block_by_hash call. println!( @@ -199,7 +196,7 @@ fn main() { println!("Querying transaction tags (kv_op=insert)..."); let query = Query { round_min: 0, - round_max: 3, + round_max: latest_round, conditions: vec![QueryCondition { key: b"kv_op".to_vec(), values: vec![b"insert".to_vec().into()],