-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from blu3beri/js/add-migration
feat(js): added migration to wrapper
- Loading branch information
Showing
23 changed files
with
381 additions
and
342 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,131 +1,18 @@ | ||
# This is a template cbindgen.toml file with all of the default values. | ||
# Some values are commented out because their absence is the real default. | ||
# | ||
# See https://github.com/eqrion/cbindgen/blob/master/docs.md#cbindgentoml | ||
# for detailed documentation of every option here. | ||
|
||
|
||
language = "C" | ||
cpp_compat = true | ||
|
||
|
||
############## Options for Wrapping the Contents of the Header ################# | ||
|
||
# header = "/* Text to put at the beginning of the generated file. Probably a license. */" | ||
# trailer = "/* Text to put at the end of the generated file */" | ||
# include_guard = "my_bindings_h" | ||
# pragma_once = true | ||
# autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" | ||
pragma_once = true | ||
autogen_warning = "/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */" | ||
include_version = false | ||
# namespace = "my_namespace" | ||
namespaces = [] | ||
using_namespaces = [] | ||
sys_includes = [] | ||
includes = [] | ||
no_includes = false | ||
after_includes = "" | ||
|
||
|
||
############################ Code Style Options ################################ | ||
|
||
braces = "SameLine" | ||
line_length = 100 | ||
tab_width = 2 | ||
documentation = true | ||
documentation_style = "auto" | ||
# documentation_length = "full" | ||
line_endings = "LF" # also "CR", "CRLF", "Native" | ||
|
||
|
||
############################# Codegen Options ################################## | ||
|
||
style = "both" | ||
sort_by = "Name" # default for `fn.sort_by` and `const.sort_by` | ||
usize_is_size_t = true | ||
|
||
|
||
[defines] | ||
# "target_os = freebsd" = "DEFINE_FREEBSD" | ||
# "feature = serde" = "DEFINE_SERDE" | ||
"feature = rich_schema" = "DEFINE_RICH_SCHEMA" | ||
"test" = "DEFINE_TEST" | ||
|
||
[export] | ||
include = [] | ||
exclude = [] | ||
# prefix = "CAPI_" | ||
item_types = [] | ||
renaming_overrides_prefixing = false | ||
|
||
|
||
[export.rename] | ||
|
||
|
||
[export.body] | ||
|
||
|
||
[export.mangle] | ||
|
||
|
||
[fn] | ||
rename_args = "None" | ||
# must_use = "MUST_USE_FUNC" | ||
# no_return = "NO_RETURN" | ||
# prefix = "START_FUNC" | ||
# postfix = "END_FUNC" | ||
args = "auto" | ||
sort_by = "Name" | ||
|
||
|
||
[struct] | ||
rename_fields = "None" | ||
# must_use = "MUST_USE_STRUCT" | ||
derive_constructor = false | ||
derive_eq = false | ||
derive_neq = false | ||
derive_lt = false | ||
derive_lte = false | ||
derive_gt = false | ||
derive_gte = false | ||
|
||
|
||
[enum] | ||
rename_variants = "None" | ||
# must_use = "MUST_USE_ENUM" | ||
add_sentinel = false | ||
prefix_with_name = false | ||
derive_helper_methods = false | ||
derive_const_casts = false | ||
derive_mut_casts = false | ||
# cast_assert_name = "ASSERT" | ||
derive_tagged_enum_destructor = false | ||
derive_tagged_enum_copy_constructor = false | ||
enum_class = true | ||
private_default_tagged_enum_constructor = false | ||
|
||
|
||
[const] | ||
allow_static_const = true | ||
allow_constexpr = false | ||
sort_by = "Name" | ||
after_includes = """ | ||
|
||
[macro_expansion] | ||
bitflags = false | ||
|
||
|
||
############## Options for How Your Rust library Should Be Parsed ############## | ||
typedef size_t ScanHandle; | ||
typedef size_t StoreHandle; | ||
typedef size_t SessionHandle; | ||
""" | ||
|
||
[parse] | ||
parse_deps = true | ||
include = ["ffi-support"] | ||
exclude = [] | ||
clean = false | ||
extra_bindings = [] | ||
|
||
|
||
[parse.expand] | ||
crates = [] | ||
all_features = false | ||
default_features = true | ||
features = [] | ||
include = ["ffi-support", "ffi"] |
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
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
6 changes: 3 additions & 3 deletions
6
wrappers/javascript/aries-askar-nodejs/tests/cryptoBox.test.ts
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
Binary file not shown.
6 changes: 4 additions & 2 deletions
6
wrappers/javascript/aries-askar-nodejs/tests/joseEcdh.test.ts
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
50 changes: 50 additions & 0 deletions
50
wrappers/javascript/aries-askar-nodejs/tests/migration.test.ts
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,50 @@ | ||
import { ariesAskar, Migration } from '@hyperledger/aries-askar-shared' | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
const DB_TEMPLATE_PATH = path.join(__dirname, 'indy_wallet_sqlite.db') | ||
const DB_UPGRADE_PATH = path.join(__dirname, 'indy_wallet_sqlite_upgraded.db') | ||
|
||
describe('migration', () => { | ||
beforeAll(() => { | ||
require('@hyperledger/aries-askar-nodejs') | ||
}) | ||
|
||
beforeEach(() => { | ||
const tplPaths = [DB_TEMPLATE_PATH, `${DB_TEMPLATE_PATH}-shm`, `${DB_TEMPLATE_PATH}-wal`] | ||
|
||
const updPaths = [DB_UPGRADE_PATH, `${DB_UPGRADE_PATH}-shm`, `${DB_UPGRADE_PATH}-wal`] | ||
|
||
for (let i = 0; i <= 3; i++) { | ||
const tplPath = tplPaths[i] | ||
const updPath = updPaths[i] | ||
|
||
if (fs.existsSync(tplPath)) { | ||
fs.copyFileSync(tplPath, updPath) | ||
} else { | ||
fs.existsSync(updPath) && fs.rmSync(updPath) | ||
} | ||
} | ||
}) | ||
|
||
test('migrate', async () => { | ||
await expect( | ||
Migration.migrate({ | ||
specUri: DB_UPGRADE_PATH, | ||
kdfLevel: 'RAW', | ||
walletName: 'walletwallet.0', | ||
walletKey: 'GfwU1DC7gEZNs3w41tjBiZYj7BNToDoFEqKY6wZXqs1A', | ||
}) | ||
).resolves.toBeUndefined() | ||
|
||
// Double migrate should not work | ||
await expect( | ||
Migration.migrate({ | ||
specUri: DB_UPGRADE_PATH, | ||
kdfLevel: 'RAW', | ||
walletName: 'walletwallet.0', | ||
walletKey: 'GfwU1DC7gEZNs3w41tjBiZYj7BNToDoFEqKY6wZXqs1A', | ||
}) | ||
).rejects.toThrowError('Database is already migrated') | ||
}) | ||
}) |
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
23 changes: 1 addition & 22 deletions
23
wrappers/javascript/aries-askar-nodejs/tests/utils/initialize.ts
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
Oops, something went wrong.