github.com/ZuluSpl0it/Sia@v1.3.7/modules/wallet/unseeded_test.go (about) 1 package wallet 2 3 import ( 4 "testing" 5 6 "github.com/NebulousLabs/Sia/modules" 7 "github.com/NebulousLabs/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, _, err := wt.wallet.ConfirmedBalance() 30 if err != nil { 31 t.Fatal(err) 32 } 33 if !siafundBal.Equals64(2000) { 34 t.Error("expecting a siafund balance of 2000 from the 1of1 key") 35 } 36 37 // Send some siafunds to the void. 38 _, err = wt.wallet.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 39 if err != nil { 40 t.Fatal(err) 41 } 42 _, err = wt.miner.AddBlock() 43 if err != nil { 44 t.Fatal(err) 45 } 46 _, siafundBal, _, err = wt.wallet.ConfirmedBalance() 47 if err != nil { 48 t.Fatal(err) 49 } 50 if !siafundBal.Equals64(1988) { 51 t.Error("expecting balance of 1988 after sending siafunds to the void") 52 } 53 } 54 55 // TestIntegrationLoad2of3Siag loads a 2 of 3 unseeded key generated by siag 56 // and then tries to spend the siafunds contained within. The key is taken from 57 // the testing keys. 58 func TestIntegrationLoad2of3Siag(t *testing.T) { 59 if testing.Short() { 60 t.SkipNow() 61 } 62 wt, err := createWalletTester(t.Name(), modules.ProdDependencies) 63 if err != nil { 64 t.Fatal(err) 65 } 66 defer wt.closeWt() 67 68 // Load the key into the wallet. 69 err = wt.wallet.LoadSiagKeys(wt.walletMasterKey, []string{"../../types/siag0of2of3.siakey", "../../types/siag1of2of3.siakey"}) 70 if err != nil { 71 t.Error(err) 72 } 73 74 _, siafundBal, _, err := wt.wallet.ConfirmedBalance() 75 if err != nil { 76 t.Fatal(err) 77 } 78 if !siafundBal.Equals64(7000) { 79 t.Error("expecting a siafund balance of 7000 from the 2of3 key") 80 } 81 82 // Send some siafunds to the void. 83 _, err = wt.wallet.SendSiafunds(types.NewCurrency64(12), types.UnlockHash{}) 84 if err != nil { 85 t.Fatal(err) 86 } 87 _, err = wt.miner.AddBlock() 88 if err != nil { 89 t.Fatal(err) 90 } 91 _, siafundBal, _, err = wt.wallet.ConfirmedBalance() 92 if err != nil { 93 t.Fatal(err) 94 } 95 if !siafundBal.Equals64(6988) { 96 t.Error("expecting balance of 6988 after sending siafunds to the void") 97 } 98 }