【发布时间】:2018-08-20 18:26:02
【问题描述】:
在流测试中发行一些现金 - 流返回交易,输出显示正确的现金状态。但是,当我查询现金状态时,没有返回任何内容。我错过了什么吗?
IssueTokensFlow
@StartableByRPC
public class IssueTokensFlow extends FlowLogic<SignedTransaction> {
private static Double amount;
public IssueTokensFlow(double amount) {
this.amount = amount;
}
@Suspendable
@Override
public SignedTransaction call() throws FlowException {
// We retrieve the notary identity from the network map.
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
// Issue cash tokens equal to transfer amount
AbstractCashFlow.Result cashIssueResult = subFlow(new CashIssueFlow(
Currencies.DOLLARS(amount), OpaqueBytes.of(Byte.parseByte("1")), notary)
);
return cashIssueResult.getStx();
} }
IssueTokenFlow 测试
@Test
public void testIssueCash() throws Exception {
IssueTokensFlow flow =
new IssueTokensFlow(100.00);
SignedTransaction transaction = a.startFlow(flow).get();
network.waitQuiescent();
Cash.State state = (Cash.State) transaction.getTx().getOutputStates().get(0);
assertEquals(state.getOwner(), chooseIdentity(a.getInfo()));
assertEquals(state.getAmount().getQuantity(), Currencies.DOLLARS(100.00).getQuantity());
// Above assertions pass
QueryCriteria.VaultQueryCriteria criteria = new QueryCriteria.VaultQueryCriteria(Vault.StateStatus.ALL);
Vault.Page<ContractState> results = a.getServices().getVaultService().queryBy(Cash.State.class, criteria);
assertTrue(results.getStates().size() > 0);
// ^ This assertion fails
}
【问题讨论】:
标签: corda