mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
CORDA-654 Make VaultFiller a class so I can change its hardcoded bits (#2141)
This commit is contained in:
@ -55,7 +55,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class VaultQueryJavaTests {
|
||||
@Rule
|
||||
public final SerializationEnvironmentRule testSerialization = new SerializationEnvironmentRule();
|
||||
private MockServices services;
|
||||
private VaultFiller vaultFiller;
|
||||
private MockServices issuerServices;
|
||||
private VaultService vaultService;
|
||||
private CordaPersistence database;
|
||||
@ -73,7 +73,8 @@ public class VaultQueryJavaTests {
|
||||
cordappPackages);
|
||||
issuerServices = new MockServices(cordappPackages, getDUMMY_CASH_ISSUER_NAME(), getDUMMY_CASH_ISSUER_KEY(), getBOC_KEY());
|
||||
database = databaseAndServices.getFirst();
|
||||
services = databaseAndServices.getSecond();
|
||||
MockServices services = databaseAndServices.getSecond();
|
||||
vaultFiller = new VaultFiller(services);
|
||||
vaultService = services.getVaultService();
|
||||
}
|
||||
|
||||
@ -93,7 +94,7 @@ public class VaultQueryJavaTests {
|
||||
@Test
|
||||
public void unconsumedLinearStates() throws VaultQueryException {
|
||||
database.transaction(tx -> {
|
||||
VaultFiller.fillWithSomeTestLinearStates(services, 3);
|
||||
vaultFiller.fillWithSomeTestLinearStates(3);
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -111,8 +112,8 @@ public class VaultQueryJavaTests {
|
||||
public void unconsumedStatesForStateRefsSortedByTxnId() {
|
||||
Vault<LinearState> issuedStates =
|
||||
database.transaction(tx -> {
|
||||
VaultFiller.fillWithSomeTestLinearStates(services, 8);
|
||||
return VaultFiller.fillWithSomeTestLinearStates(services, 2);
|
||||
vaultFiller.fillWithSomeTestLinearStates(8);
|
||||
return vaultFiller.fillWithSomeTestLinearStates(2);
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
Stream<StateRef> stateRefsStream = StreamSupport.stream(issuedStates.getStates().spliterator(), false).map(StateAndRef::getRef);
|
||||
@ -137,7 +138,7 @@ public class VaultQueryJavaTests {
|
||||
public void consumedCashStates() {
|
||||
Amount<Currency> amount = new Amount<>(100, Currency.getInstance("USD"));
|
||||
database.transaction(tx -> {
|
||||
VaultFiller.fillWithSomeTestCash(services,
|
||||
vaultFiller.fillWithSomeTestCash(
|
||||
new Amount<Currency>(100, Currency.getInstance("USD")),
|
||||
issuerServices,
|
||||
TestConstants.getDUMMY_NOTARY(),
|
||||
@ -149,7 +150,7 @@ public class VaultQueryJavaTests {
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
VaultFiller.consumeCash(services, amount, getDUMMY_NOTARY());
|
||||
vaultFiller.consumeCash(amount, getDUMMY_NOTARY());
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -170,17 +171,16 @@ public class VaultQueryJavaTests {
|
||||
@SuppressWarnings("unchecked")
|
||||
Triple<StateAndRef<LinearState>, UniqueIdentifier, Vault<DealState>> ids =
|
||||
database.transaction((DatabaseTransaction tx) -> {
|
||||
Vault<LinearState> states = VaultFiller.fillWithSomeTestLinearStates(services, 10, null);
|
||||
Vault<LinearState> states = vaultFiller.fillWithSomeTestLinearStates(10, null);
|
||||
StateAndRef<LinearState> linearState = states.getStates().iterator().next();
|
||||
UniqueIdentifier uid = linearState.component1().getData().getLinearId();
|
||||
|
||||
Vault<DealState> dealStates = VaultFiller.fillWithSomeTestDeals(services, dealIds);
|
||||
Vault<DealState> dealStates = vaultFiller.fillWithSomeTestDeals(dealIds);
|
||||
return new Triple(linearState, uid, dealStates);
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
// consume states
|
||||
VaultFiller.consumeDeals(services, (List<? extends StateAndRef<? extends DealState>>) ids.getThird().getStates(), getDUMMY_NOTARY());
|
||||
VaultFiller.consumeLinearStates(services, Collections.singletonList(ids.getFirst()), getDUMMY_NOTARY());
|
||||
vaultFiller.consumeDeals((List<? extends StateAndRef<? extends DealState>>) ids.getThird().getStates(), getDUMMY_NOTARY());
|
||||
vaultFiller.consumeLinearStates(Collections.singletonList(ids.getFirst()), getDUMMY_NOTARY());
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -219,11 +219,10 @@ public class VaultQueryJavaTests {
|
||||
Amount<Currency> dollars100 = new Amount<>(100, Currency.getInstance("USD"));
|
||||
Amount<Currency> dollars10 = new Amount<>(10, Currency.getInstance("USD"));
|
||||
Amount<Currency> dollars1 = new Amount<>(1, Currency.getInstance("USD"));
|
||||
|
||||
VaultFiller.fillWithSomeTestCash(services, pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars10, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars1, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars10, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars1, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -260,7 +259,7 @@ public class VaultQueryJavaTests {
|
||||
@Test
|
||||
public void trackCashStates() {
|
||||
database.transaction(tx -> {
|
||||
VaultFiller.fillWithSomeTestCash(services,
|
||||
vaultFiller.fillWithSomeTestCash(
|
||||
new Amount<>(100, Currency.getInstance("USD")),
|
||||
issuerServices,
|
||||
TestConstants.getDUMMY_NOTARY(),
|
||||
@ -294,10 +293,9 @@ public class VaultQueryJavaTests {
|
||||
List<String> dealIds = Arrays.asList("123", "456", "789");
|
||||
UniqueIdentifier uid =
|
||||
database.transaction(tx -> {
|
||||
Vault<LinearState> states = VaultFiller.fillWithSomeTestLinearStates(services, 10, null);
|
||||
Vault<LinearState> states = vaultFiller.fillWithSomeTestLinearStates(10, null);
|
||||
UniqueIdentifier _uid = states.getStates().iterator().next().component1().getData().getLinearId();
|
||||
|
||||
VaultFiller.fillWithSomeTestDeals(services, dealIds);
|
||||
vaultFiller.fillWithSomeTestDeals(dealIds);
|
||||
return _uid;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -341,13 +339,11 @@ public class VaultQueryJavaTests {
|
||||
Amount<Currency> dollars300 = new Amount<>(300, Currency.getInstance("USD"));
|
||||
Amount<Currency> pounds = new Amount<>(400, Currency.getInstance("GBP"));
|
||||
Amount<Currency> swissfrancs = new Amount<>(500, Currency.getInstance("CHF"));
|
||||
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, swissfrancs, issuerServices, TestConstants.getDUMMY_NOTARY(), 5, 5, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
|
||||
vaultFiller.fillWithSomeTestCash(dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(swissfrancs, issuerServices, TestConstants.getDUMMY_NOTARY(), 5, 5, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -389,13 +385,11 @@ public class VaultQueryJavaTests {
|
||||
Amount<Currency> dollars300 = new Amount<>(300, Currency.getInstance("USD"));
|
||||
Amount<Currency> pounds = new Amount<>(400, Currency.getInstance("GBP"));
|
||||
Amount<Currency> swissfrancs = new Amount<>(500, Currency.getInstance("CHF"));
|
||||
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, swissfrancs, issuerServices, TestConstants.getDUMMY_NOTARY(), 5, 5, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
|
||||
vaultFiller.fillWithSomeTestCash(dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(pounds, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(swissfrancs, issuerServices, TestConstants.getDUMMY_NOTARY(), 5, 5, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
@ -452,12 +446,10 @@ public class VaultQueryJavaTests {
|
||||
Amount<Currency> dollars200 = new Amount<>(200, Currency.getInstance("USD"));
|
||||
Amount<Currency> pounds300 = new Amount<>(300, Currency.getInstance("GBP"));
|
||||
Amount<Currency> pounds400 = new Amount<>(400, Currency.getInstance("GBP"));
|
||||
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getBOC().ref(new OpaqueBytes("1".getBytes())));
|
||||
VaultFiller.fillWithSomeTestCash(services, pounds300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
VaultFiller.fillWithSomeTestCash(services, pounds400, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getBOC().ref(new OpaqueBytes("1".getBytes())));
|
||||
|
||||
vaultFiller.fillWithSomeTestCash(dollars100, issuerServices, TestConstants.getDUMMY_NOTARY(), 1, 1, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(dollars200, issuerServices, TestConstants.getDUMMY_NOTARY(), 2, 2, new Random(0L), null, getBOC().ref(new OpaqueBytes("1".getBytes())));
|
||||
vaultFiller.fillWithSomeTestCash(pounds300, issuerServices, TestConstants.getDUMMY_NOTARY(), 3, 3, new Random(0L), null, getDUMMY_CASH_ISSUER());
|
||||
vaultFiller.fillWithSomeTestCash(pounds400, issuerServices, TestConstants.getDUMMY_NOTARY(), 4, 4, new Random(0L), null, getBOC().ref(new OpaqueBytes("1".getBytes())));
|
||||
return tx;
|
||||
});
|
||||
database.transaction(tx -> {
|
||||
|
@ -38,7 +38,7 @@ import net.corda.node.services.persistence.DBTransactionStorage
|
||||
import net.corda.node.services.persistence.checkpoints
|
||||
import net.corda.node.utilities.CordaPersistence
|
||||
import net.corda.testing.*
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
import net.corda.testing.contracts.VaultFiller
|
||||
import net.corda.testing.node.*
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.After
|
||||
@ -106,7 +106,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
bobNode.internals.disableDBCloseOnStop()
|
||||
|
||||
bobNode.database.transaction {
|
||||
bobNode.services.fillWithSomeTestCash(2000.DOLLARS, bankNode.services, outputNotary = notary,
|
||||
VaultFiller(bobNode.services).fillWithSomeTestCash(2000.DOLLARS, bankNode.services, outputNotary = notary,
|
||||
issuedBy = cashIssuer)
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
bobNode.internals.disableDBCloseOnStop()
|
||||
|
||||
val cashStates = bobNode.database.transaction {
|
||||
bobNode.services.fillWithSomeTestCash(2000.DOLLARS, bankNode.services, notary, 3, 3,
|
||||
VaultFiller(bobNode.services).fillWithSomeTestCash(2000.DOLLARS, bankNode.services, notary, 3, 3,
|
||||
issuedBy = issuer)
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ class TwoPartyTradeFlowTests(private val anonymous: Boolean) {
|
||||
val issuer = bank.ref(1, 2, 3)
|
||||
|
||||
bobNode.database.transaction {
|
||||
bobNode.services.fillWithSomeTestCash(2000.DOLLARS, bankNode.services, outputNotary = notary,
|
||||
VaultFiller(bobNode.services).fillWithSomeTestCash(2000.DOLLARS, bankNode.services, outputNotary = notary,
|
||||
issuedBy = issuer)
|
||||
}
|
||||
val alicesFakePaper = aliceNode.database.transaction {
|
||||
|
@ -33,10 +33,7 @@ import net.corda.node.services.vault.VaultSchemaV1
|
||||
import net.corda.node.utilities.CordaPersistence
|
||||
import net.corda.node.utilities.configureDatabase
|
||||
import net.corda.testing.*
|
||||
import net.corda.testing.contracts.consumeCash
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
import net.corda.testing.contracts.fillWithSomeTestDeals
|
||||
import net.corda.testing.contracts.fillWithSomeTestLinearStates
|
||||
import net.corda.testing.contracts.*
|
||||
import net.corda.testing.node.MockServices
|
||||
import net.corda.testing.node.MockServices.Companion.makeTestDataSourceProperties
|
||||
import net.corda.testing.schemas.DummyLinearStateSchemaV1
|
||||
@ -57,6 +54,7 @@ class HibernateConfigurationTest {
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
lateinit var services: MockServices
|
||||
private lateinit var vaultFiller: VaultFiller
|
||||
lateinit var bankServices: MockServices
|
||||
lateinit var issuerServices: MockServices
|
||||
lateinit var notaryServices: MockServices
|
||||
@ -108,6 +106,7 @@ class HibernateConfigurationTest {
|
||||
|
||||
override fun jdbcSession() = database.createSession()
|
||||
}
|
||||
vaultFiller = VaultFiller(services)
|
||||
hibernatePersister = services.hibernatePersister
|
||||
}
|
||||
|
||||
@ -117,7 +116,7 @@ class HibernateConfigurationTest {
|
||||
|
||||
database.transaction {
|
||||
val numStates = 10
|
||||
cashStates = services.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, numStates, numStates, Random(0L), issuedBy = issuer.ref(1))
|
||||
cashStates = vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, numStates, numStates, Random(0L), issuedBy = issuer.ref(1))
|
||||
.states.toList()
|
||||
}
|
||||
|
||||
@ -148,7 +147,7 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `consumed states`() {
|
||||
database.transaction {
|
||||
services.consumeCash(50.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(50.DOLLARS, notary = notary)
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -160,7 +159,7 @@ class HibernateConfigurationTest {
|
||||
// execute query
|
||||
val queryResults = entityManager.createQuery(criteriaQuery).resultList
|
||||
val coins = queryResults.map {
|
||||
(services.loadState(toStateRef(it.stateRef!!)) as TransactionState<Cash.State>).data
|
||||
services.loadState(toStateRef(it.stateRef!!)).data
|
||||
}.sumCash()
|
||||
assertThat(coins.toDecimal() >= BigDecimal("50.00"))
|
||||
}
|
||||
@ -169,8 +168,8 @@ class HibernateConfigurationTest {
|
||||
fun `select by composite primary key`() {
|
||||
val issuedStates =
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(8)
|
||||
services.fillWithSomeTestLinearStates(2)
|
||||
vaultFiller.fillWithSomeTestLinearStates(8)
|
||||
vaultFiller.fillWithSomeTestLinearStates(2)
|
||||
}
|
||||
val persistentStateRefs = issuedStates.states.map { PersistentStateRef(it.ref) }.toList()
|
||||
|
||||
@ -194,8 +193,8 @@ class HibernateConfigurationTest {
|
||||
fun `distinct contract types`() {
|
||||
database.transaction {
|
||||
// add 2 more contract types
|
||||
services.fillWithSomeTestLinearStates(10)
|
||||
services.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
vaultFiller.fillWithSomeTestLinearStates(10)
|
||||
vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -229,11 +228,11 @@ class HibernateConfigurationTest {
|
||||
fun `with sorting by state ref desc and asc`() {
|
||||
// generate additional state ref indexes
|
||||
database.transaction {
|
||||
services.consumeCash(1.DOLLARS, notary = notary)
|
||||
services.consumeCash(2.DOLLARS, notary = notary)
|
||||
services.consumeCash(3.DOLLARS, notary = notary)
|
||||
services.consumeCash(4.DOLLARS, notary = notary)
|
||||
services.consumeCash(5.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(1.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(2.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(3.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(4.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(5.DOLLARS, notary = notary)
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -259,11 +258,11 @@ class HibernateConfigurationTest {
|
||||
fun `with sorting by state ref index and txId desc and asc`() {
|
||||
// generate additional state ref indexes
|
||||
database.transaction {
|
||||
services.consumeCash(1.DOLLARS, notary = notary)
|
||||
services.consumeCash(2.DOLLARS, notary = notary)
|
||||
services.consumeCash(3.DOLLARS, notary = notary)
|
||||
services.consumeCash(4.DOLLARS, notary = notary)
|
||||
services.consumeCash(5.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(1.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(2.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(3.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(4.DOLLARS, notary = notary)
|
||||
vaultFiller.consumeCash(5.DOLLARS, notary = notary)
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -290,7 +289,7 @@ class HibernateConfigurationTest {
|
||||
fun `with pagination`() {
|
||||
// add 100 additional cash entries
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(1000.POUNDS, issuerServices, notary, 100, 100, Random(0L), issuedBy = issuer.ref(1))
|
||||
vaultFiller.fillWithSomeTestCash(1000.POUNDS, issuerServices, notary, 100, 100, Random(0L), issuedBy = issuer.ref(1))
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -321,7 +320,7 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `select by composite primary key on LinearStates`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(10)
|
||||
vaultFiller.fillWithSomeTestLinearStates(10)
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -372,8 +371,7 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `select and join by composite primary key on CashStates`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(5)
|
||||
|
||||
vaultFiller.fillWithSomeTestLinearStates(5)
|
||||
// structure query
|
||||
val criteriaQuery = criteriaBuilder.createQuery(VaultSchemaV1.VaultStates::class.java)
|
||||
val vaultStates = criteriaQuery.from(VaultSchemaV1.VaultStates::class.java)
|
||||
@ -391,12 +389,11 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `calculate cash balances`() {
|
||||
database.transaction {
|
||||
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 10, issuer.ref(1)) // +$100 = $200
|
||||
services.fillWithSomeTestCash(50.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // £50 = £50
|
||||
services.fillWithSomeTestCash(25.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // +£25 = £175
|
||||
services.fillWithSomeTestCash(500.SWISS_FRANCS, issuerServices, notary, 10, issuer.ref(1)) // CHF500 = CHF500
|
||||
services.fillWithSomeTestCash(250.SWISS_FRANCS, issuerServices, notary, 5, issuer.ref(1)) // +CHF250 = CHF750
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 10, issuer.ref(1)) // +$100 = $200
|
||||
vaultFiller.fillWithSomeTestCash(50.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // £50 = £50
|
||||
vaultFiller.fillWithSomeTestCash(25.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // +£25 = £175
|
||||
vaultFiller.fillWithSomeTestCash(500.SWISS_FRANCS, issuerServices, notary, 10, issuer.ref(1)) // CHF500 = CHF500
|
||||
vaultFiller.fillWithSomeTestCash(250.SWISS_FRANCS, issuerServices, notary, 5, issuer.ref(1)) // +CHF250 = CHF750
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -425,8 +422,8 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `calculate cash balance for single currency`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(50.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // £50 = £50
|
||||
services.fillWithSomeTestCash(25.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // +£25 = £175
|
||||
vaultFiller.fillWithSomeTestCash(50.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // £50 = £50
|
||||
vaultFiller.fillWithSomeTestCash(25.POUNDS, issuerServices, notary, 5, issuer.ref(1)) // +£25 = £175
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -456,9 +453,9 @@ class HibernateConfigurationTest {
|
||||
fun `calculate and order by cash balance for owner and currency`() {
|
||||
database.transaction {
|
||||
val bank = bankServices.myInfo.legalIdentities.single()
|
||||
services.fillWithSomeTestCash(200.DOLLARS, bankServices, notary, 2, bank.ref(1))
|
||||
services.fillWithSomeTestCash(300.POUNDS, issuerServices, notary, 3, issuer.ref(1))
|
||||
services.fillWithSomeTestCash(400.POUNDS, bankServices, notary, 4, bank.ref(2))
|
||||
vaultFiller.fillWithSomeTestCash(200.DOLLARS, bankServices, notary, 2, bank.ref(1))
|
||||
vaultFiller.fillWithSomeTestCash(300.POUNDS, issuerServices, notary, 3, issuer.ref(1))
|
||||
vaultFiller.fillWithSomeTestCash(400.POUNDS, bankServices, notary, 4, bank.ref(2))
|
||||
}
|
||||
|
||||
// structure query
|
||||
@ -518,8 +515,7 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `select by composite primary key on CashStates in V2`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(5)
|
||||
|
||||
vaultFiller.fillWithSomeTestLinearStates(5)
|
||||
// persist cash states explicitly with V2 schema
|
||||
cashStates.forEach {
|
||||
val cashState = it.state.data
|
||||
@ -554,9 +550,9 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `select by composite primary between VaultStates, VaultLinearStates and DummyLinearStates`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(8)
|
||||
services.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
services.fillWithSomeTestLinearStates(2)
|
||||
vaultFiller.fillWithSomeTestLinearStates(8)
|
||||
vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
vaultFiller.fillWithSomeTestLinearStates(2)
|
||||
}
|
||||
val sessionFactory = sessionFactoryForSchemas(VaultSchemaV1, DummyLinearStateSchemaV1)
|
||||
val criteriaBuilder = sessionFactory.criteriaBuilder
|
||||
@ -585,9 +581,9 @@ class HibernateConfigurationTest {
|
||||
@Test
|
||||
fun `three way join by composite primary between VaultStates, VaultLinearStates and DummyLinearStates`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(8)
|
||||
services.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
services.fillWithSomeTestLinearStates(2)
|
||||
vaultFiller.fillWithSomeTestLinearStates(8)
|
||||
vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"))
|
||||
vaultFiller.fillWithSomeTestLinearStates(2)
|
||||
}
|
||||
val sessionFactory = sessionFactoryForSchemas(VaultSchemaV1, DummyLinearStateSchemaV2)
|
||||
val criteriaBuilder = sessionFactory.criteriaBuilder
|
||||
@ -644,10 +640,9 @@ class HibernateConfigurationTest {
|
||||
val dummyFungibleState = DummyFungibleContract.State(cashState.amount, cashState.owner)
|
||||
hibernatePersister.persistStateWithSchema(dummyFungibleState, it.ref, SampleCashSchemaV3)
|
||||
}
|
||||
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 2, 2, Random(0L),
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 2, 2, Random(0L),
|
||||
issuedBy = issuer.ref(1), owner = ALICE)
|
||||
val cashStates = services.fillWithSomeTestCash(100.DOLLARS, services, notary, 2, identity.ref(0)).states
|
||||
val cashStates = vaultFiller.fillWithSomeTestCash(100.DOLLARS, services, notary, 2, identity.ref(0)).states
|
||||
// persist additional cash states explicitly with V3 schema
|
||||
cashStates.forEach {
|
||||
val cashState = it.state.data
|
||||
@ -723,8 +718,7 @@ class HibernateConfigurationTest {
|
||||
val dummyFungibleState = DummyFungibleContract.State(cashState.amount, cashState.owner)
|
||||
hibernatePersister.persistStateWithSchema(dummyFungibleState, it.ref, SampleCashSchemaV3)
|
||||
}
|
||||
|
||||
val moreCash = services.fillWithSomeTestCash(100.DOLLARS, services, notary, 2, 2, Random(0L),
|
||||
val moreCash = vaultFiller.fillWithSomeTestCash(100.DOLLARS, services, notary, 2, 2, Random(0L),
|
||||
issuedBy = identity.ref(0), owner = identity).states
|
||||
// persist additional cash states explicitly with V3 schema
|
||||
moreCash.forEach {
|
||||
@ -732,8 +726,7 @@ class HibernateConfigurationTest {
|
||||
val dummyFungibleState = DummyFungibleContract.State(cashState.amount, cashState.owner)
|
||||
hibernatePersister.persistStateWithSchema(dummyFungibleState, it.ref, SampleCashSchemaV3)
|
||||
}
|
||||
|
||||
val cashStates = services.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 2, 2, Random(0L), owner = ALICE, issuedBy = issuer.ref(1)).states
|
||||
val cashStates = vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, notary, 2, 2, Random(0L), owner = ALICE, issuedBy = issuer.ref(1)).states
|
||||
// persist additional cash states explicitly with V3 schema
|
||||
cashStates.forEach {
|
||||
val cashState = it.state.data
|
||||
@ -777,9 +770,9 @@ class HibernateConfigurationTest {
|
||||
fun `with sorting on attribute from common table`() {
|
||||
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(1, externalId = "111")
|
||||
services.fillWithSomeTestLinearStates(2, externalId = "222")
|
||||
services.fillWithSomeTestLinearStates(3, externalId = "333")
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, externalId = "111")
|
||||
vaultFiller.fillWithSomeTestLinearStates(2, externalId = "222")
|
||||
vaultFiller.fillWithSomeTestLinearStates(3, externalId = "333")
|
||||
}
|
||||
val sessionFactory = sessionFactoryForSchemas(VaultSchemaV1, DummyLinearStateSchemaV2)
|
||||
val criteriaBuilder = sessionFactory.criteriaBuilder
|
||||
@ -829,9 +822,9 @@ class HibernateConfigurationTest {
|
||||
fun `with sorting on attribute from custom table`() {
|
||||
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(1, externalId = "111")
|
||||
services.fillWithSomeTestLinearStates(2, externalId = "222")
|
||||
services.fillWithSomeTestLinearStates(3, externalId = "333")
|
||||
vaultFiller.fillWithSomeTestLinearStates(1, externalId = "111")
|
||||
vaultFiller.fillWithSomeTestLinearStates(2, externalId = "222")
|
||||
vaultFiller.fillWithSomeTestLinearStates(3, externalId = "333")
|
||||
}
|
||||
val sessionFactory = sessionFactoryForSchemas(VaultSchemaV1, DummyLinearStateSchemaV1)
|
||||
val criteriaBuilder = sessionFactory.criteriaBuilder
|
||||
|
@ -36,7 +36,7 @@ import net.corda.finance.schemas.CashSchemaV1
|
||||
import net.corda.finance.utils.sumCash
|
||||
import net.corda.node.utilities.CordaPersistence
|
||||
import net.corda.testing.*
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
import net.corda.testing.contracts.VaultFiller
|
||||
import net.corda.testing.node.MockServices
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
@ -62,6 +62,7 @@ class NodeVaultServiceTest {
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule()
|
||||
private lateinit var services: MockServices
|
||||
private lateinit var vaultFiller: VaultFiller
|
||||
private lateinit var identity: PartyAndCertificate
|
||||
private lateinit var issuerServices: MockServices
|
||||
private lateinit var bocServices: MockServices
|
||||
@ -74,6 +75,7 @@ class NodeVaultServiceTest {
|
||||
val databaseAndServices = MockServices.makeTestDatabaseAndMockServices(cordappPackages = cordappPackages)
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
vaultFiller = VaultFiller(services)
|
||||
// This is safe because MockServices only ever have a single identity
|
||||
identity = services.myInfo.singleIdentityAndCert()
|
||||
issuerServices = MockServices(cordappPackages, DUMMY_CASH_ISSUER_NAME, DUMMY_CASH_ISSUER_KEY)
|
||||
@ -111,7 +113,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `states not local to instance`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
val w1 = vaultService.queryBy<Cash.State>().states
|
||||
@ -136,7 +138,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `states for refs`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
val w1 = vaultService.queryBy<Cash.State>().states
|
||||
@ -150,7 +152,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `states soft locking reserve and release`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
|
||||
@ -203,7 +205,7 @@ class NodeVaultServiceTest {
|
||||
val vaultStates =
|
||||
database.transaction {
|
||||
assertEquals(0.DOLLARS, services.getCashBalance(USD))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
val stateRefsToSoftLock = (vaultStates.states.map { it.ref }).toNonEmptySet()
|
||||
println("State Refs:: $stateRefsToSoftLock")
|
||||
@ -258,7 +260,7 @@ class NodeVaultServiceTest {
|
||||
val vaultStates =
|
||||
database.transaction {
|
||||
assertEquals(0.DOLLARS, services.getCashBalance(USD))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
val stateRefsToSoftLock = vaultStates.states.map { it.ref }
|
||||
println("State Refs:: $stateRefsToSoftLock")
|
||||
@ -286,7 +288,7 @@ class NodeVaultServiceTest {
|
||||
val vaultStates =
|
||||
database.transaction {
|
||||
assertEquals(0.DOLLARS, services.getCashBalance(USD))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
val stateRefsToSoftLock = (vaultStates.states.map { it.ref }).toNonEmptySet()
|
||||
println("State Refs:: $stateRefsToSoftLock")
|
||||
@ -313,7 +315,7 @@ class NodeVaultServiceTest {
|
||||
val vaultStates =
|
||||
database.transaction {
|
||||
assertEquals(0.DOLLARS, services.getCashBalance(USD))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L))
|
||||
}
|
||||
val stateRefsToSoftLock = vaultStates.states.map { it.ref }
|
||||
println("State Refs:: $stateRefsToSoftLock")
|
||||
@ -334,7 +336,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `unconsumedStatesForSpending exact amount`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
|
||||
@ -353,8 +355,8 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `unconsumedStatesForSpending from two issuer parties`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
services.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(1))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(1))
|
||||
}
|
||||
database.transaction {
|
||||
val spendableStatesUSD = vaultService.unconsumedCashStatesForSpending(200.DOLLARS,
|
||||
@ -370,10 +372,10 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `unconsumedStatesForSpending from specific issuer party and refs`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
services.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(1))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(2))
|
||||
services.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(3))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(1))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(2))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, bocServices, DUMMY_NOTARY, 1, 1, Random(0L), issuedBy = BOC.ref(3))
|
||||
}
|
||||
database.transaction {
|
||||
val unconsumedStates = vaultService.queryBy<Cash.State>().states
|
||||
@ -392,7 +394,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `unconsumedStatesForSpending insufficient amount`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
val unconsumedStates = vaultService.queryBy<Cash.State>().states
|
||||
@ -409,7 +411,7 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `unconsumedStatesForSpending small amount`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 2, 2, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 2, 2, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
val unconsumedStates = vaultService.queryBy<Cash.State>().states
|
||||
@ -427,9 +429,9 @@ class NodeVaultServiceTest {
|
||||
@Test
|
||||
fun `states soft locking query granularity`() {
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
services.fillWithSomeTestCash(100.POUNDS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
services.fillWithSomeTestCash(100.SWISS_FRANCS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.POUNDS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.SWISS_FRANCS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
var unlockedStates = 30
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -51,6 +51,7 @@ class VaultWithCashTest {
|
||||
@JvmField
|
||||
val testSerialization = SerializationEnvironmentRule(true)
|
||||
lateinit var services: MockServices
|
||||
private lateinit var vaultFiller: VaultFiller
|
||||
lateinit var issuerServices: MockServices
|
||||
val vaultService: VaultService get() = services.vaultService
|
||||
lateinit var database: CordaPersistence
|
||||
@ -63,6 +64,7 @@ class VaultWithCashTest {
|
||||
val databaseAndServices = makeTestDatabaseAndMockServices(cordappPackages = cordappPackages, keys = listOf(generateKeyPair(), DUMMY_NOTARY_KEY))
|
||||
database = databaseAndServices.first
|
||||
services = databaseAndServices.second
|
||||
vaultFiller = VaultFiller(services)
|
||||
issuerServices = MockServices(cordappPackages, DUMMY_CASH_ISSUER_NAME, DUMMY_CASH_ISSUER_KEY, MEGA_CORP_KEY)
|
||||
notaryServices = MockServices(cordappPackages, DUMMY_NOTARY.name, DUMMY_NOTARY_KEY)
|
||||
notary = notaryServices.myInfo.legalIdentitiesAndCerts.single().party
|
||||
@ -78,7 +80,7 @@ class VaultWithCashTest {
|
||||
fun splits() {
|
||||
database.transaction {
|
||||
// Fix the PRNG so that we get the same splits every time.
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L), issuedBy = DUMMY_CASH_ISSUER)
|
||||
}
|
||||
database.transaction {
|
||||
val w = vaultService.queryBy<Cash.State>().states
|
||||
@ -148,7 +150,7 @@ class VaultWithCashTest {
|
||||
|
||||
database.transaction {
|
||||
// A tx that sends us money.
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L), owner = AnonymousParty(freshKey),
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 10, 10, Random(0L), owner = AnonymousParty(freshKey),
|
||||
issuedBy = MEGA_CORP.ref(1))
|
||||
println("Cash balance: ${services.getCashBalance(USD)}")
|
||||
}
|
||||
@ -298,16 +300,16 @@ class VaultWithCashTest {
|
||||
|
||||
val freshKey = services.keyManagementService.freshKey()
|
||||
database.transaction {
|
||||
services.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L), owner = AnonymousParty(freshKey))
|
||||
services.fillWithSomeTestCash(100.SWISS_FRANCS, issuerServices, DUMMY_NOTARY, 2, 2, Random(0L))
|
||||
services.fillWithSomeTestCash(100.POUNDS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.DOLLARS, issuerServices, DUMMY_NOTARY, 3, 3, Random(0L), owner = AnonymousParty(freshKey))
|
||||
vaultFiller.fillWithSomeTestCash(100.SWISS_FRANCS, issuerServices, DUMMY_NOTARY, 2, 2, Random(0L))
|
||||
vaultFiller.fillWithSomeTestCash(100.POUNDS, issuerServices, DUMMY_NOTARY, 1, 1, Random(0L))
|
||||
}
|
||||
database.transaction {
|
||||
val cash = vaultService.queryBy<Cash.State>().states
|
||||
cash.forEach { println(it.state.data.amount) }
|
||||
}
|
||||
database.transaction {
|
||||
services.fillWithSomeTestDeals(listOf("123", "456", "789"), issuerServices)
|
||||
vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"), issuerServices)
|
||||
}
|
||||
database.transaction {
|
||||
val deals = vaultService.queryBy<DummyDealContract.State>().states
|
||||
@ -337,14 +339,14 @@ class VaultWithCashTest {
|
||||
val freshKey = services.keyManagementService.freshKey()
|
||||
val freshIdentity = AnonymousParty(freshKey)
|
||||
database.transaction {
|
||||
services.fillWithSomeTestDeals(listOf("123", "456", "789"), issuerServices)
|
||||
vaultFiller.fillWithSomeTestDeals(listOf("123", "456", "789"), issuerServices)
|
||||
}
|
||||
val deals =
|
||||
database.transaction {
|
||||
vaultService.queryBy<DummyDealContract.State>().states
|
||||
}
|
||||
database.transaction {
|
||||
services.fillWithSomeTestLinearStates(3)
|
||||
vaultFiller.fillWithSomeTestLinearStates(3)
|
||||
}
|
||||
database.transaction {
|
||||
val linearStates = vaultService.queryBy<DummyLinearContract.State>().states
|
||||
|
Reference in New Issue
Block a user