github.com/Finschia/finschia-sdk@v0.48.1/types/invariant.go (about) 1 package types 2 3 import "fmt" 4 5 // An Invariant is a function which tests a particular invariant. 6 // The invariant returns a descriptive message about what happened 7 // and a boolean indicating whether the invariant has been broken. 8 // The simulator will then halt and print the logs. 9 type Invariant func(ctx Context) (string, bool) 10 11 // Invariants defines a group of invariants 12 type Invariants []Invariant 13 14 // expected interface for registering invariants 15 type InvariantRegistry interface { 16 RegisterRoute(moduleName, route string, invar Invariant) 17 } 18 19 // FormatInvariant returns a standardized invariant message. 20 func FormatInvariant(module, name, msg string) string { 21 return fmt.Sprintf("%s: %s invariant\n%s\n", module, name, msg) 22 }