public final class NodeFake extends Object implements Node
try (TemporaryDb db = TemporaryDb.newInstance();
Cleaner cleaner = new Cleaner()) {
// Setup database to include some test data
Fork fork = db.createFork(cleaner);
MapIndex balance = MapIndexProxy.newInstance("balance", fork, stringSerializer,
stringSerializer);
balance.put("John Doe", "$1000.00");
db.merge(fork);
// Create a node fake from the database
NodeFake node = new NodeFake(db);
WalletController controller = new WalletController(node);
assertThat(controller.getBalance("John Doe"), equalTo("$1000.00"));
}
| Constructor and Description |
|---|
NodeFake(TemporaryDb database)
Creates a new node fake with the given database and an empty public key.
|
NodeFake(TemporaryDb database,
com.exonum.binding.common.crypto.PublicKey publicKey)
Creates a new node fake with the given database.
|
| Modifier and Type | Method and Description |
|---|---|
TemporaryDb |
getDatabase()
Returns the underlying database.
|
com.exonum.binding.common.crypto.PublicKey |
getPublicKey()
Returns the service public key of this node.
|
com.exonum.binding.common.hash.HashCode |
submitTransaction(RawTransaction transaction)
Returns a zero hash always, ignoring the transaction.
|
<ResultT> ResultT |
withSnapshot(Function<Snapshot,ResultT> snapshotFunction)
Performs the given function with a snapshot of the current database state.
|
public NodeFake(TemporaryDb database)
database - a database to provide snapshots ofpublic NodeFake(TemporaryDb database, com.exonum.binding.common.crypto.PublicKey publicKey)
database - a database to provide snapshots ofpublicKey - a public key of the nodepublic com.exonum.binding.common.hash.HashCode submitTransaction(RawTransaction transaction)
submitTransaction in interface Nodetransaction - a transaction to sendNullPointerException - if the transaction is nullBlockchain.getTxMessages()public <ResultT> ResultT withSnapshot(Function<Snapshot,ResultT> snapshotFunction)
NodewithSnapshot in interface NodeResultT - a type the function returnssnapshotFunction - a function to executepublic com.exonum.binding.common.crypto.PublicKey getPublicKey()
NodeNode.submitTransaction(RawTransaction).
This key is stored under "service_public_key" key in the node configuration file.
getPublicKey in interface Nodepublic TemporaryDb getDatabase()
Copyright © 2019 Exonum. All rights reserved.