github.com/nebulouslabs/sia@v1.3.7/modules/wallet/dependencies_test.go (about) 1 package wallet 2 3 import "github.com/NebulousLabs/Sia/modules" 4 5 type ( 6 // dependencyAcceptTxnSetFailed is a dependency used to cause a call to 7 // SendSiacoins and SendSiacoinsMulti to fail before AcceptTransactionSet 8 // is called 9 dependencySendSiacoinsInterrupted struct { 10 modules.ProductionDependencies 11 f bool // indicates if the next call should fail 12 } 13 14 // dependencyDefragInterrupted is a dependency used to cause a defrag to 15 // fail before AcceptTransactionSet is called 16 dependencyDefragInterrupted struct { 17 modules.ProductionDependencies 18 f bool // indicates if the next call should fail 19 } 20 ) 21 22 // Disrupt will return true if fail was called and the correct string value is 23 // provided. It also resets f back to false. This means fail has to be called 24 // once for each Send that should fail. 25 func (d *dependencySendSiacoinsInterrupted) Disrupt(s string) bool { 26 if d.f && s == "SendSiacoinsInterrupted" { 27 d.f = false 28 return true 29 } 30 return false 31 } 32 33 // fail causes the next SendSiacoinsInterrupted disrupt to return true 34 func (d *dependencySendSiacoinsInterrupted) fail() { 35 d.f = true 36 } 37 38 // Disrupt will return true if fail was called and the correct string value is 39 // provided. It also resets f back to false. This means fail has to be called 40 // once for each Defrag that should fail. 41 func (d *dependencyDefragInterrupted) Disrupt(s string) bool { 42 if d.f && s == "DefragInterrupted" { 43 d.f = false 44 return true 45 } 46 return false 47 } 48 49 // fail causes the next DefragInterrupted disrupt to return true 50 func (d *dependencyDefragInterrupted) fail() { 51 d.f = true 52 }