wasm_storage_conformance (wasm_storage v0.1.0)
View SourceThe checks every storage provider must pass, as plain functions.
The wasm_storage contract (the storage contract) is checked case
by case against a provider you describe with two funs. Run it from Common
Test for your own provider:
all() -> wasm_storage_conformance:cases().
init_per_testcase(_, Config) ->
Dir = ?config(priv_dir, Config),
Path = filename:join(Dir, "dev"),
[{target, #{open => fun() -> wasm_storage:open({my_provider, Path},
#{create => true}) end,
reopen => fun() -> wasm_storage:open({my_provider, Path},
#{}) end}}
| Config].
Case(Config) ->
ok = wasm_storage_conformance:run(Case, ?config(target, Config)).open returns a fresh, empty device. reopen, optional, returns a second
handle to the same device; the cases that need it are skipped without it.
A failing case raises error({conformance, Case, Detail}).
Summary
Types
-type target() :: #{open := fun(() -> {ok, wasm_storage:handle()}), reopen => fun(() -> {ok, wasm_storage:handle()})}.