github.com/deroproject/derosuite@v2.1.6-1.0.20200307070847-0f2e589c7a2b+incompatible/walletapi/db_test.go (about) 1 package walletapi 2 3 import "os" 4 import "bytes" 5 import "path/filepath" 6 import "testing" 7 8 //import "fmt" 9 10 import "github.com/deroproject/derosuite/crypto" 11 12 // quick testing of wallet creation 13 func Test_Wallet_DB(t *testing.T) { 14 15 temp_db := filepath.Join(os.TempDir(), "dero_temporary_test_wallet.db") 16 17 os.Remove(temp_db) 18 w, err := Create_Encrypted_Wallet(temp_db, "QWER", *crypto.RandomScalar()) 19 if err != nil { 20 t.Fatalf("Cannot create encrypted wallet, err %s", err) 21 } 22 w.Close_Encrypted_Wallet() 23 24 w, err = Open_Encrypted_Wallet(temp_db, "QWER") 25 if err != nil { 26 t.Fatalf("Cannot open encrypted wallet, err %s", err) 27 } 28 29 os.Remove(temp_db) 30 31 // test deterministc keys 32 key := []byte("test") 33 34 if !bytes.Equal(w.Key2Key(key), w.Key2Key(key)) { 35 t.Fatalf("Key2Key failed") 36 } 37 38 w.Close_Encrypted_Wallet() 39 40 }