5 changed files with 54 additions and 53 deletions
@ -1,10 +1,16 @@ |
|||
package com.sparrowwallet.sparrow.io; |
|||
|
|||
import java.io.File; |
|||
import java.io.InputStream; |
|||
|
|||
public class IoTest { |
|||
public static final String IO_TEST_PATH = "/com/sparrowwallet/sparrow/io/"; |
|||
|
|||
protected File getFile(String filename) { |
|||
return new File(this.getClass().getResource(IO_TEST_PATH + filename).getFile()); |
|||
} |
|||
|
|||
protected InputStream getInputStream(String filename) { |
|||
return this.getClass().getResourceAsStream("/com/sparrowwallet/sparrow/io/" + filename); |
|||
return this.getClass().getResourceAsStream(IO_TEST_PATH + filename); |
|||
} |
|||
} |
|||
|
@ -0,0 +1,36 @@ |
|||
package com.sparrowwallet.sparrow.io; |
|||
|
|||
import com.sparrowwallet.drongo.crypto.ECKey; |
|||
import com.sparrowwallet.drongo.wallet.Wallet; |
|||
import org.junit.Assert; |
|||
import org.junit.Test; |
|||
|
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
|
|||
public class StorageTest extends IoTest { |
|||
@Test |
|||
public void loadWallet() throws IOException { |
|||
ECKey decryptionKey = ECKey.createKeyPbkdf2HmacSha512("pass"); |
|||
Wallet wallet = Storage.getStorage().loadWallet(getFile("sparrow-single-wallet"), decryptionKey); |
|||
Assert.assertTrue(wallet.isValid()); |
|||
} |
|||
|
|||
@Test |
|||
public void saveWallet() throws IOException { |
|||
ECKey decryptionKey = ECKey.createKeyPbkdf2HmacSha512("pass"); |
|||
Wallet wallet = Storage.getStorage().loadWallet(getFile("sparrow-single-wallet"), decryptionKey); |
|||
Assert.assertTrue(wallet.isValid()); |
|||
|
|||
ECKey encyptionKey = ECKey.fromPublicOnly(decryptionKey); |
|||
File tempWallet = File.createTempFile("sparrow", "tmp"); |
|||
tempWallet.deleteOnExit(); |
|||
|
|||
ByteArrayOutputStream dummyFileOutputStream = new ByteArrayOutputStream(); |
|||
Storage.getStorage().storeWallet(tempWallet, encyptionKey, wallet); |
|||
|
|||
wallet = Storage.getStorage().loadWallet(tempWallet, decryptionKey); |
|||
Assert.assertTrue(wallet.isValid()); |
|||
} |
|||
} |
@ -0,0 +1 @@ |
|||
QklFMQNI/quQo9N7RtbygK+yhlrMNxkSnXtlaC9Ia5trm7AufOtbKhGqrtv5bQ/YcRVVaj/eKhO7LWTGbC6EWFYbIle/tpTyQB5XdceCCWmbUDwyob+thVpMLLrVe9PQD+EH6GM2cWGFUZNMHdYM2N/EaLU4Z2nnDz9pLzg1jpOtU9n3D1IeivULxfkupsd0AqxkpkXJlc0y7udh2qzXk/BPffYkEN0NexspO2+I1+o81g1IcVRXNV7LR8o/woKRM4MPBhUNVOy2F5JyvKnsteBKpEpKa4AyHmhGRtIdyKIZK4+osIU9Ig+b/AItDj9OG354gpL7oiU65s7rF8UsJpDLtxIyONUL6becqsNNem0rTbHQ0PI1uoWHmQj8dUl8sqhdIwC13Hhnx0+M5ICrqs3gk5tkUyiCDA7684jrWLGRjUzUXRPmNJsWPqlnCD2+MY93dduMwbJqV1USrOZDXsMd9LuGAV+UqEDMuBRjwXDxXQldrIBp9QKYac1mKFvj9UOJr062T2gwGsSyKY2R6oCiGJPkOZjRoQ0HHwJukFYJgoRRI34Hnh49LUfJybv+VEfqz9VJZhWnDhCgcFZ9r1BwY4CZ |
Loading…
Reference in new issue