github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/modules/wallet/unseeded_test.go (about) 1 package wallet 2 3 import ( 4 "testing" 5 6 "github.com/NebulousLabs/Sia/types" 7 ) 8 9 // TestIntegrationLoad1of1Siag loads a 1 of 1 unseeded key generated by siag 10 // and then tries to spend the siafunds contained within. The key is taken from 11 // the testing keys. 12 func TestIntegrationLoad1of1Siag(t *testing.T) { 13 if testing.Short() { 14 t.SkipNow() 15 } 16 wt, err := createWalletTester("TestIntegrationLoad1of1Siag") 17 if err != nil { 18 t.Fatal(err) 19 } 20 21 // Load the key into the wallet. 22 err = wt.wallet.LoadSiagKeys(wt.walletMasterKey, []string{"../../types/siag0of1of1.siakey"}) 23 if err != nil { 24 t.Error(err) 25 } 26 27 // Create a second wallet that loads the persist structures of the existing 28 // wallet. This wallet should have a siafund balance. 29 w, err := New(wt.cs, wt.tpool, wt.wallet.persistDir) 30 if err != nil { 31 t.Fatal(err) 32 } 33 err = w.Unlock(wt.walletMasterKey) 34 if err != nil { 35 t.Fatal(err) 36 } 37 _, siafundBal, _ := w.ConfirmedBalance() 38 if siafundBal.Cmp(types.NewCurrency64(2000)) != 0 { 39 t.Error("expecting a siafund balance of 2000 from the 1of1 key") 40 } 41 42 // Send some siafunds to the void. 43 _, err = w.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 44 if err != nil { 45 t.Fatal(err) 46 } 47 _, err = wt.miner.AddBlock() 48 if err != nil { 49 t.Fatal(err) 50 } 51 _, siafundBal, _ = w.ConfirmedBalance() 52 if siafundBal.Cmp(types.NewCurrency64(1988)) != 0 { 53 t.Error("expecting balance of 1988 after sending siafunds to the void") 54 } 55 } 56 57 // TestIntegrationLoad2of3Siag loads a 2 of 3 unseeded key generated by siag 58 // and then tries to spend the siafunds contained within. The key is taken from 59 // the testing keys. 60 func TestIntegrationLoad2of3Siag(t *testing.T) { 61 if testing.Short() { 62 t.SkipNow() 63 } 64 wt, err := createWalletTester("TestIntegrationLoad2of3Siag") 65 if err != nil { 66 t.Fatal(err) 67 } 68 69 // Load the key into the wallet. 70 err = wt.wallet.LoadSiagKeys(wt.walletMasterKey, []string{"../../types/siag0of2of3.siakey", "../../types/siag1of2of3.siakey"}) 71 if err != nil { 72 t.Error(err) 73 } 74 75 // Create a second wallet that loads the persist structures of the existing 76 // wallet. This wallet should have a siafund balance. 77 w, err := New(wt.cs, wt.tpool, wt.wallet.persistDir) 78 if err != nil { 79 t.Fatal(err) 80 } 81 err = w.Unlock(wt.walletMasterKey) 82 if err != nil { 83 t.Fatal(err) 84 } 85 _, siafundBal, _ := w.ConfirmedBalance() 86 if siafundBal.Cmp(types.NewCurrency64(7000)) != 0 { 87 t.Error("expecting a siafund balance of 7000 from the 2of3 key") 88 } 89 90 // Send some siafunds to the void. 91 _, err = w.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 92 if err != nil { 93 t.Fatal(err) 94 } 95 _, err = wt.miner.AddBlock() 96 if err != nil { 97 t.Fatal(err) 98 } 99 _, siafundBal, _ = w.ConfirmedBalance() 100 if siafundBal.Cmp(types.NewCurrency64(6988)) != 0 { 101 t.Error("expecting balance of 6988 after sending siafunds to the void") 102 } 103 }