node: Relax TwoPartyTradeProtocolTests so it only checks a subsequence of store accesses

This commit is contained in:
Andras Slemmer
2016-09-08 15:15:50 +01:00
parent ca93f33356
commit 0fc560d20a

View File

@ -298,17 +298,19 @@ class TwoPartyTradeProtocolTests {
run { run {
val records = (bobNode.storage.validatedTransactions as RecordingTransactionStorage).records val records = (bobNode.storage.validatedTransactions as RecordingTransactionStorage).records
// Check Bobs's database accesses as Bob's cash transactions are downloaded by Alice. // Check Bobs's database accesses as Bob's cash transactions are downloaded by Alice.
assertThat(records).containsExactly( records.expectEvents(isStrict = false) {
// Buyer Bob is told about Alice's commercial paper, but doesn't know it .. sequence(
TxRecord.Get(alicesFakePaper[0].id), // Buyer Bob is told about Alice's commercial paper, but doesn't know it ..
// He asks and gets the tx, validates it, sees it's a self issue with no dependencies, stores. expect(TxRecord.Get(alicesFakePaper[0].id)),
TxRecord.Add(alicesSignedTxns.values.first()), // He asks and gets the tx, validates it, sees it's a self issue with no dependencies, stores.
// Alice gets Bob's proposed transaction and doesn't know his two cash states. She asks, Bob answers. expect(TxRecord.Add(alicesSignedTxns.values.first())),
TxRecord.Get(bobsFakeCash[1].id), // Alice gets Bob's proposed transaction and doesn't know his two cash states. She asks, Bob answers.
TxRecord.Get(bobsFakeCash[2].id), expect(TxRecord.Get(bobsFakeCash[1].id)),
// Alice notices that Bob's cash txns depend on a third tx she also doesn't know. She asks, Bob answers. expect(TxRecord.Get(bobsFakeCash[2].id)),
TxRecord.Get(bobsFakeCash[0].id) // Alice notices that Bob's cash txns depend on a third tx she also doesn't know. She asks, Bob answers.
) expect(TxRecord.Get(bobsFakeCash[0].id))
)
}
// Bob has downloaded the attachment. // Bob has downloaded the attachment.
bobNode.storage.attachments.openAttachment(attachmentID)!!.openAsJAR().use { bobNode.storage.attachments.openAttachment(attachmentID)!!.openAsJAR().use {
@ -321,33 +323,35 @@ class TwoPartyTradeProtocolTests {
// And from Alice's perspective ... // And from Alice's perspective ...
run { run {
val records = (aliceNode.storage.validatedTransactions as RecordingTransactionStorage).records val records = (aliceNode.storage.validatedTransactions as RecordingTransactionStorage).records
assertThat(records).containsExactly( records.expectEvents(isStrict = false) {
// Seller Alice sends her seller info to Bob, who wants to check the asset for sale. sequence(
// He requests, Alice looks up in her DB to send the tx to Bob // Seller Alice sends her seller info to Bob, who wants to check the asset for sale.
TxRecord.Get(alicesFakePaper[0].id), // He requests, Alice looks up in her DB to send the tx to Bob
// Seller Alice gets a proposed tx which depends on Bob's two cash txns and her own tx. expect(TxRecord.Get(alicesFakePaper[0].id)),
TxRecord.Get(bobsFakeCash[1].id), // Seller Alice gets a proposed tx which depends on Bob's two cash txns and her own tx.
TxRecord.Get(bobsFakeCash[2].id), expect(TxRecord.Get(bobsFakeCash[1].id)),
TxRecord.Get(alicesFakePaper[0].id), expect(TxRecord.Get(bobsFakeCash[2].id)),
// Alice notices that Bob's cash txns depend on a third tx she also doesn't know. expect(TxRecord.Get(alicesFakePaper[0].id)),
TxRecord.Get(bobsFakeCash[0].id), // Alice notices that Bob's cash txns depend on a third tx she also doesn't know.
// Bob answers with the transactions that are now all verifiable, as Alice bottomed out. expect(TxRecord.Get(bobsFakeCash[0].id)),
// Bob's transactions are valid, so she commits to the database // Bob answers with the transactions that are now all verifiable, as Alice bottomed out.
TxRecord.Add(bobsSignedTxns[bobsFakeCash[0].id]!!), // Bob's transactions are valid, so she commits to the database
TxRecord.Get(bobsFakeCash[0].id), // Verify expect(TxRecord.Add(bobsSignedTxns[bobsFakeCash[0].id]!!)),
TxRecord.Add(bobsSignedTxns[bobsFakeCash[2].id]!!), expect(TxRecord.Get(bobsFakeCash[0].id)), // Verify
TxRecord.Get(bobsFakeCash[0].id), // Verify expect(TxRecord.Add(bobsSignedTxns[bobsFakeCash[2].id]!!)),
TxRecord.Add(bobsSignedTxns[bobsFakeCash[1].id]!!), expect(TxRecord.Get(bobsFakeCash[0].id)), // Verify
// Now she verifies the transaction is contract-valid (not signature valid) which means expect(TxRecord.Add(bobsSignedTxns[bobsFakeCash[1].id]!!)),
// looking up the states again. // Now she verifies the transaction is contract-valid (not signature valid) which means
TxRecord.Get(bobsFakeCash[1].id), // looking up the states again.
TxRecord.Get(bobsFakeCash[2].id), expect(TxRecord.Get(bobsFakeCash[1].id)),
TxRecord.Get(alicesFakePaper[0].id), expect(TxRecord.Get(bobsFakeCash[2].id)),
// Alice needs to look up the input states to find out which Notary they point to expect(TxRecord.Get(alicesFakePaper[0].id)),
TxRecord.Get(bobsFakeCash[1].id), // Alice needs to look up the input states to find out which Notary they point to
TxRecord.Get(bobsFakeCash[2].id), expect(TxRecord.Get(bobsFakeCash[1].id)),
TxRecord.Get(alicesFakePaper[0].id) expect(TxRecord.Get(bobsFakeCash[2].id)),
) expect(TxRecord.Get(alicesFakePaper[0].id))
)
}
} }
} }
} }