Skip to content

Commit

Permalink
Merge pull request #2542 from oasislabs/kostko/fix/rt-cli-2531
Browse files Browse the repository at this point in the history
Fix simple-keyvalue-client crash
  • Loading branch information
kostko authored Jan 13, 2020
2 parents 83df083 + 71e63ec commit d29e701
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .changelog/2542.bugfix.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 2 additions & 2 deletions go/runtime/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions tests/clients/simple-keyvalue/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down Expand Up @@ -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()],
Expand Down

0 comments on commit d29e701

Please sign in to comment.