-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/oasis-test-runner/scenario/e2e/runtime: Add kv_enc test client
- Loading branch information
Showing
7 changed files
with
349 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
go/oasis-test-runner/scenario/e2e/runtime/runtime_client_kv.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package runtime | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/oasisprotocol/oasis-core/go/common" | ||
"github.com/oasisprotocol/oasis-core/go/common/cbor" | ||
"github.com/oasisprotocol/oasis-core/go/oasis-test-runner/env" | ||
) | ||
|
||
var BasicKVTestClient = NewBinaryTestClient( | ||
"simple-keyvalue-client", | ||
nil, | ||
) | ||
|
||
// KeyValueTestClient is a client that exercises the simple key-value | ||
// test runtime. | ||
type KeyValueTestClient struct { | ||
sc *runtimeImpl | ||
} | ||
|
||
func (cli *KeyValueTestClient) Init(scenario *runtimeImpl) error { | ||
cli.sc = scenario | ||
return nil | ||
} | ||
|
||
func (cli *KeyValueTestClient) Start(ctx context.Context, childEnv *env.Env) error { | ||
panic("not implemented") | ||
} | ||
|
||
func (cli *KeyValueTestClient) Wait() error { | ||
panic("not implemented") | ||
} | ||
|
||
func (cli *KeyValueTestClient) Clone() TestClient { | ||
panic("not implemented") | ||
} | ||
|
||
func NewKeyValueTestClient() *KeyValueTestClient { | ||
panic("not implemented") | ||
} | ||
|
||
func (sc *runtimeImpl) submitKeyValueRuntimeInsertTx( | ||
ctx context.Context, | ||
id common.Namespace, | ||
key, value string, | ||
nonce uint64, | ||
) error { | ||
_, err := sc.submitRuntimeTx(ctx, id, "insert", struct { | ||
Key string `json:"key"` | ||
Value string `json:"value"` | ||
Nonce uint64 `json:"nonce"` | ||
}{ | ||
Key: key, | ||
Value: value, | ||
Nonce: nonce, | ||
}) | ||
return err | ||
} | ||
|
||
func (sc *runtimeImpl) submitKeyValueRuntimeGetTx( | ||
ctx context.Context, | ||
id common.Namespace, | ||
key string, | ||
nonce uint64, | ||
) (string, error) { | ||
rawRsp, err := sc.submitRuntimeTx(ctx, runtimeID, "get", struct { | ||
Key string `json:"key"` | ||
Nonce uint64 `json:"nonce"` | ||
}{ | ||
Key: key, | ||
Nonce: nonce, | ||
}) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to submit get tx to runtime: %w", err) | ||
} | ||
|
||
var rsp string | ||
if err = cbor.Unmarshal(rawRsp, &rsp); err != nil { | ||
return "", fmt.Errorf("failed to unmarshal response from runtime: %w", err) | ||
} | ||
|
||
return rsp, nil | ||
} |
Oops, something went wrong.