github.com/Synthesix/Sia@v1.3.3-0.20180413141344-f863baeed3ca/modules/wallet/unseeded_test.go (about) 1 package wallet 2 3 import ( 4 "testing" 5 6 "github.com/Synthesix/Sia/modules" 7 "github.com/Synthesix/Sia/types" 8 ) 9 10 // TestIntegrationLoad1of1Siag loads a 1 of 1 unseeded key generated by siag 11 // and then tries to spend the siafunds contained within. The key is taken from 12 // the testing keys. 13 func TestIntegrationLoad1of1Siag(t *testing.T) { 14 if testing.Short() { 15 t.SkipNow() 16 } 17 wt, err := createWalletTester(t.Name(), modules.ProdDependencies) 18 if err != nil { 19 t.Fatal(err) 20 } 21 defer wt.closeWt() 22 23 // Load the key into the wallet. 24 err = wt.wallet.LoadSiagKeys(wt.walletMasterKey, []string{"../../types/siag0of1of1.siakey"}) 25 if err != nil { 26 t.Error(err) 27 } 28 29 _, siafundBal, _ := wt.wallet.ConfirmedBalance() 30 if !siafundBal.Equals64(2000) { 31 t.Error("expecting a siafund balance of 2000 from the 1of1 key") 32 } 33 34 // Send some siafunds to the void. 35 _, err = wt.wallet.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 36 if err != nil { 37 t.Fatal(err) 38 } 39 _, err = wt.miner.AddBlock() 40 if err != nil { 41 t.Fatal(err) 42 } 43 _, siafundBal, _ = wt.wallet.ConfirmedBalance() 44 if !siafundBal.Equals64(1988) { 45 t.Error("expecting balance of 1988 after sending siafunds to the void") 46 } 47 } 48 49 // TestIntegrationLoad2of3Siag loads a 2 of 3 unseeded key generated by siag 50 // and then tries to spend the siafunds contained within. The key is taken from 51 // the testing keys. 52 func TestIntegrationLoad2of3Siag(t *testing.T) { 53 if testing.Short() { 54 t.SkipNow() 55 } 56 wt, err := createWalletTester(t.Name(), modules.ProdDependencies) 57 if err != nil { 58 t.Fatal(err) 59 } 60 defer wt.closeWt() 61 62 // Load the key into the wallet. 63 err = wt.wallet.LoadSiagKeys(wt.walletMasterKey, []string{"../../types/siag0of2of3.siakey", "../../types/siag1of2of3.siakey"}) 64 if err != nil { 65 t.Error(err) 66 } 67 68 _, siafundBal, _ := wt.wallet.ConfirmedBalance() 69 if !siafundBal.Equals64(7000) { 70 t.Error("expecting a siafund balance of 7000 from the 2of3 key") 71 } 72 73 // Send some siafunds to the void. 74 _, err = wt.wallet.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 75 if err != nil { 76 t.Fatal(err) 77 } 78 _, err = wt.miner.AddBlock() 79 if err != nil { 80 t.Fatal(err) 81 } 82 _, siafundBal, _ = wt.wallet.ConfirmedBalance() 83 if !siafundBal.Equals64(6988) { 84 t.Error("expecting balance of 6988 after sending siafunds to the void") 85 } 86 }