This repository has been archived by the owner on Aug 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stops submitting zero val bundles to the spent addresses service
- Loading branch information
1 parent
490bf73
commit 8f2a242
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/com/iota/iri/service/spentaddresses/impl/SpentAddressesServiceImplTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.iota.iri.service.spentaddresses.impl; | ||
|
||
import com.iota.iri.BundleValidator; | ||
import com.iota.iri.TangleMockUtils; | ||
import com.iota.iri.controllers.TransactionViewModel; | ||
import com.iota.iri.service.snapshot.SnapshotProvider; | ||
import com.iota.iri.service.spentaddresses.SpentAddressesProvider; | ||
import com.iota.iri.storage.Tangle; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.MockitoJUnit; | ||
import org.mockito.junit.MockitoRule; | ||
|
||
import java.util.List; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.*; | ||
|
||
public class SpentAddressesServiceImplTest { | ||
|
||
@Rule | ||
public MockitoRule mockitoRule = MockitoJUnit.rule(); | ||
|
||
@Mock | ||
private Tangle tangle; | ||
|
||
@Mock | ||
private BundleValidator bundleValidator; | ||
|
||
@Mock | ||
private SnapshotProvider snapshotProvider; | ||
|
||
@Mock | ||
private SpentAddressesProvider spentAddressesProvider; | ||
|
||
@Test | ||
public void doesntPersistZeroValueBundles() throws Exception { | ||
SpentAddressesServiceImpl spentAddressesService = new SpentAddressesServiceImpl(); | ||
spentAddressesService.init(tangle, snapshotProvider, spentAddressesProvider, bundleValidator, null); | ||
List<TransactionViewModel> bundle = TangleMockUtils.mockValidBundle(tangle, bundleValidator, 1); | ||
spentAddressesService.persistValidatedSpentAddressesAsync(bundle); | ||
verify(spentAddressesProvider, never()).saveAddressesBatch(any()); | ||
} | ||
} |