github.com/NebulousLabs/Sia@v1.3.7/modules/consensus/dependencies_test.go (about) 1 package consensus 2 3 import "github.com/NebulousLabs/Sia/modules" 4 5 type ( 6 // dependencySleepAfterInitializeSubscribe is a dependency used to make the consensusSet sleep for a few seconds after calling managedInitializeSubscribe. 7 dependencySleepAfterInitializeSubscribe struct { 8 modules.ProductionDependencies 9 f bool // indicates if the next call should fail 10 } 11 ) 12 13 // Disrupt will return true if fail was called and the correct string value is 14 // provided. It also resets f back to false. This means fail has to be called 15 // once for each Send that should fail. 16 func (d *dependencySleepAfterInitializeSubscribe) Disrupt(s string) bool { 17 if d.f && s == "SleepAfterInitializeSubscribe" { 18 d.f = false 19 return true 20 } 21 return false 22 } 23 24 // enable causes the next "SleepAfterInitializeSubscribe" - disrupt of this 25 // dependency to return true 26 func (d *dependencySleepAfterInitializeSubscribe) enable() { 27 d.f = true 28 }