Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug where open with initialData didn't affect that kv class #6

Merged
merged 1 commit into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class SecoKeyval {
this._data = JSON.parse(data.toString('utf8'))
} else {
await this._seco.write(expand32k(gzipSync(Buffer.from(JSON.stringify(initalData)))))
this._data = {}
this._data = initalData
}

this.hasOpened = true
Expand Down
5 changes: 5 additions & 0 deletions src/seco-keyval.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ test('SecoKeyval open() with initalData / get()', async (t) => {
let kv = new SecoKeyval(walletFile, { appName: 'test', appVersion: '1.0.0' })
await kv.open(passphrase, data)

let kvData = {}
kvData.person1 = await kv.get('person1')
kvData.person2 = await kv.get('person2')
t.same(kvData, data, 'data is availible')

// verify the file actually got created
t.true(await fs.pathExists(walletFile), 'wallet exists')

Expand Down