Fixed app tests for state spaces

This commit is contained in:
Ethan Frey
2017-07-11 15:21:02 +02:00
parent 771c08483e
commit 66d1f86098
2 changed files with 27 additions and 3 deletions
+15 -1
View File
@@ -26,6 +26,20 @@ func stateSpace(store state.KVStore, app string) state.KVStore {
store = pstore.store
}
// wrap it with the prefix
prefix := append([]byte(app), byte(0))
prefix := makePrefix(app)
return prefixStore{prefix, store}
}
func makePrefix(app string) []byte {
return append([]byte(app), byte(0))
}
// PrefixedKey gives us the absolute path to a key that is embedded in an
// application-specific state-space.
//
// This is useful for tests or utilities that have access to the global
// state to check individual app spaces. Individual apps should not be able
// to use this to read each other's space
func PrefixedKey(app string, key []byte) []byte {
return append(makePrefix(app), key...)
}