Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

testImportAndExport not working... #291

Open
ashishonmobile opened this issue Apr 6, 2019 · 6 comments
Open

testImportAndExport not working... #291

ashishonmobile opened this issue Apr 6, 2019 · 6 comments

Comments

@ashishonmobile
Copy link

I am trying to run below test but is failing and saying invalidAccountError

`func testImportAndExport() throws {
let json = """
{"version":3,"id":"8b60fda9-5f27-4478-9cc9-72059571aa6e","crypto":{"ciphertext":"d34e78640359a599970a58b3b4b7c987945e56c69411028ea62394e8d1ea7e4b","cipherparams":{"iv":"6e4a429a30807ab9202a9aefad152398"},"kdf":"scrypt","kdfparams":{"r":6,"p":1,"n":4096,"dklen":32,"salt":"0000000000000000000000000000000000000000000000000000000000000000"},"mac":"79888d6ce3a2a24d6b70d07ca9067b57e4a57bd9416a3abb336900cacf82e29a","cipher":"aes-128-cbc"},"address":"0b0f7a95485060973726d03e7c326a6542bcb55b"}
"""
let keystore = EthereumKeystoreV3(json)!
let data = try keystore.serialize()!
let key = try keystore.UNSAFE_getPrivateKeyData(password: "hello world", account: keystore.addresses[0]).hex

    let keystore2 = EthereumKeystoreV3(data)!
    let data2 = try keystore2.serialize()!
    let key2 = try keystore2.UNSAFE_getPrivateKeyData(password: "hello world", account: keystore.addresses[0]).hex
    
    XCTAssertEqual(data,data2)
    XCTAssertEqual(key,key2)

}`

is there anyone who can help me what I am doing wrong.

Regards,
Ashish

@ashishonmobile
Copy link
Author

ashishonmobile commented Apr 6, 2019

I tried mine one too but did not work.

@ashishonmobile
Copy link
Author

` let json = """
{"version":3,"id":"8ea94370-4ce1-4fe4-b0ba-5bdeedb6d437","address":"950e813d1a6f5b256bd0679d90115522786cf1b1","crypto":{"ciphertext":"fefcd42e80087ba4c009100fcee3204b6ba039a430b8f7ba32417487d71245b3","cipherparams":{"iv":"132b360258db5b4b473302f863803438"},"cipher":"aes-128-ctr","kdf":"scrypt","kdfparams":{"dklen":32,"salt":"4d731b14cc425cb6fae6274d19b8220df3fa995a271d2886644e0b7686b1e70d","n":131072,"r":8,"p":1},"mac":"8227957b5e800a692548bf32af8732c3cec6c18e20f7f7b930a9b8b14315ba32"}}
"""
let keystore = EthereumKeystoreV3(json)!
let data = try keystore.serialize()!
let key = try keystore.UNSAFE_getPrivateKeyData(password: "A1B2A1B2C4DDDE", account: keystore.addresses[0]).hex

    let keystore2 = EthereumKeystoreV3(data)!
    let data2 = try keystore2.serialize()!
    let key2 = try keystore2.UNSAFE_getPrivateKeyData(password: "A1B2A1B2C4DDDE", account: keystore.addresses[0]).hex
  `

Try this one .

@ashishonmobile
Copy link
Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ashishonmobile and others