diff --git a/src/main/kotlin/core/node/services/NodeWalletService.kt b/src/main/kotlin/core/node/services/NodeWalletService.kt index f193d0eaa8..86f0749bca 100644 --- a/src/main/kotlin/core/node/services/NodeWalletService.kt +++ b/src/main/kotlin/core/node/services/NodeWalletService.kt @@ -139,7 +139,7 @@ class NodeWalletService(private val services: ServiceHub) : WalletService { * TODO: Move this out of NodeWalletService */ fun fillWithSomeTestCash(howMuch: Amount, atLeastThisManyStates: Int = 3, atMostThisManyStates: Int = 10, - rng: Random = Random()): Wallet { + rng: Random = Random()) { val amounts = calculateRandomlySizedAmounts(howMuch, atLeastThisManyStates, atMostThisManyStates, rng) val myIdentity = services.storageService.myLegalIdentity @@ -160,10 +160,7 @@ class NodeWalletService(private val services: ServiceHub) : WalletService { return@map issuance.toSignedTransaction(true) } - // TODO: Centralise the process of transaction acceptance and filtering into the wallet, then move this out. - services.storageService.validatedTransactions.putAll(transactions.associateBy { it.id }) - - return notifyAll(transactions.map { it.tx }) + services.recordTransactions(transactions) } private fun calculateRandomlySizedAmounts(howMuch: Amount, min: Int, max: Int, rng: Random): LongArray { diff --git a/src/test/kotlin/core/MockServices.kt b/src/test/kotlin/core/MockServices.kt index 2aaf7bf1a6..80ce99aad9 100644 --- a/src/test/kotlin/core/MockServices.kt +++ b/src/test/kotlin/core/MockServices.kt @@ -91,7 +91,7 @@ class MockAttachmentStorage : AttachmentStorage { class MockStorageService : StorageServiceImpl(MockAttachmentStorage(), generateKeyPair()) class MockServices( - val wallet: WalletService? = null, + customWallet: WalletService? = null, val keyManagement: KeyManagementService? = null, val net: MessagingService? = null, val identity: IdentityService? = MockIdentityService, @@ -99,8 +99,8 @@ class MockServices( val networkMap: NetworkMapCache? = MockNetworkMapCache(), val overrideClock: Clock? = Clock.systemUTC() ) : ServiceHub { - override val walletService: WalletService - get() = wallet ?: throw UnsupportedOperationException() + override val walletService: WalletService = customWallet ?: NodeWalletService(this) + override val keyManagementService: KeyManagementService get() = keyManagement ?: throw UnsupportedOperationException() override val identityService: IdentityService diff --git a/src/test/kotlin/core/node/NodeWalletServiceTest.kt b/src/test/kotlin/core/node/NodeWalletServiceTest.kt index 735afe3195..8999811e04 100644 --- a/src/test/kotlin/core/node/NodeWalletServiceTest.kt +++ b/src/test/kotlin/core/node/NodeWalletServiceTest.kt @@ -15,7 +15,6 @@ import kotlin.test.assertNull class NodeWalletServiceTest { val kms = MockKeyManagementService(ALICE_KEY) - val services: ServiceHub = MockServices(keyManagement = kms) @Before fun setUp() { @@ -27,9 +26,15 @@ class NodeWalletServiceTest { BriefLogFormatter.loggingOff(NodeWalletService::class) } + fun make(): Pair { + val services = MockServices(keyManagement = kms) + return Pair(services.walletService as NodeWalletService, services) + } + @Test fun splits() { - val wallet = NodeWalletService(services) + val (wallet, services) = make() + kms.nextKeys += Array(3) { ALICE_KEY } // Fix the PRNG so that we get the same splits every time. wallet.fillWithSomeTestCash(100.DOLLARS, 3, 3, Random(0L)) @@ -49,7 +54,7 @@ class NodeWalletServiceTest { @Test fun basics() { - val wallet = NodeWalletService(services) + val (wallet, services) = make() // A tx that sends us money. val freshKey = services.keyManagementService.freshKey()