|
|
|
|
@ -25,7 +25,10 @@ import java.util.Optional;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThat;
|
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
|
|
import static org.mockito.Mockito.never;
|
|
|
|
|
import static org.mockito.Mockito.times;
|
|
|
|
|
import static org.mockito.Mockito.verify;
|
|
|
|
|
import static org.mockito.Mockito.when;
|
|
|
|
|
import static org.mockito.ArgumentMatchers.anyList;
|
|
|
|
|
@ -73,7 +76,7 @@ class DigitalCurrencyProductionAndOwnershipServiceTest {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void signsEveryCoinWithTheCentralBankFirstKeyAndPersistsTheOperator() {
|
|
|
|
|
void centralConfirmationSignsCoinsButDoesNotActivateThemBeforeCommercialBankVerification() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
ReserveDeductionNotificationRepository notificationRepository = mock(ReserveDeductionNotificationRepository.class);
|
|
|
|
|
@ -90,6 +93,7 @@ class DigitalCurrencyProductionAndOwnershipServiceTest {
|
|
|
|
|
.thenReturn(Optional.<DigitalCurrencyOwnershipConfirmation>empty());
|
|
|
|
|
when(notificationRepository.findByRequestId(requestId)).thenReturn(Optional.of(notification(requestId)));
|
|
|
|
|
when(gateway.centralBankSigningKeyId()).thenReturn(InstitutionKeyService.CENTRAL_FIRST_KEY);
|
|
|
|
|
when(gateway.digest(org.mockito.ArgumentMatchers.anyString())).thenReturn("BATCH_DIGEST");
|
|
|
|
|
when(gateway.signOwnership(org.mockito.ArgumentMatchers.eq(subject), org.mockito.ArgumentMatchers.anyString()))
|
|
|
|
|
.thenReturn("OWNERSHIP_SIGNATURE");
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service =
|
|
|
|
|
@ -97,8 +101,12 @@ class DigitalCurrencyProductionAndOwnershipServiceTest {
|
|
|
|
|
|
|
|
|
|
DigitalCurrencyProductionBatchView result = service.confirm(requestId, actor, subject);
|
|
|
|
|
|
|
|
|
|
assertThat(result.getStatus()).isEqualTo("OWNERSHIP_CONFIRMED");
|
|
|
|
|
assertThat(result.getStatus()).isEqualTo("OWNERSHIP_SIGNED");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getStatus()).isEqualTo("CENTRAL_CONFIRMED");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getSigningKeyId()).isEqualTo(InstitutionKeyService.CENTRAL_FIRST_KEY);
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getConfirmationOriginalText()).contains("MINT_001", "DC_001");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getConfirmationDigest()).isEqualTo("BATCH_DIGEST");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getCentralBankSignature()).isEqualTo("OWNERSHIP_SIGNATURE");
|
|
|
|
|
assertThat(result.getDraftCoins().get(0).getOwnershipSignature()).isEqualTo("OWNERSHIP_SIGNATURE");
|
|
|
|
|
assertThat(result.getDraftCoins().get(0).getOwnershipOriginalText()).isEqualTo("SOURCE_COMPLETE_CURRENCY");
|
|
|
|
|
assertThat(result.getDraftCoins().get(0).getCompleteCurrency())
|
|
|
|
|
@ -109,13 +117,224 @@ class DigitalCurrencyProductionAndOwnershipServiceTest {
|
|
|
|
|
ArgumentCaptor<DigitalCurrencyOwnershipConfirmation> confirmationCaptor =
|
|
|
|
|
ArgumentCaptor.forClass(DigitalCurrencyOwnershipConfirmation.class);
|
|
|
|
|
verify(repository).confirmOwnership(batchCaptor.capture(), confirmationCaptor.capture());
|
|
|
|
|
verify(gateway).activateGeneratedCurrencies(org.mockito.ArgumentMatchers.eq(subject),
|
|
|
|
|
org.mockito.ArgumentMatchers.eq(requestId), org.mockito.ArgumentMatchers.eq("BK01"),
|
|
|
|
|
org.mockito.ArgumentMatchers.eq("ORG_001"), org.mockito.ArgumentMatchers.anyList(),
|
|
|
|
|
verify(gateway, never()).activateGeneratedCurrencies(org.mockito.ArgumentMatchers.eq(subject),
|
|
|
|
|
org.mockito.ArgumentMatchers.eq(requestId), org.mockito.ArgumentMatchers.anyString(),
|
|
|
|
|
org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyList(),
|
|
|
|
|
org.mockito.ArgumentMatchers.eq(actor));
|
|
|
|
|
assertThat(confirmationCaptor.getValue().getSigningKeyId()).isEqualTo(InstitutionKeyService.CENTRAL_FIRST_KEY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void activatesCurrenciesAndSignsReceiptOnlyAfterCommercialBankVerification() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
ReserveDeductionNotificationRepository notificationRepository = mock(ReserveDeductionNotificationRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DraftDigitalCurrency coin = new DraftDigitalCurrency("DC_001", "MINT_001", 1, new BigDecimal("100.00"),
|
|
|
|
|
"ORG_001", "DC", "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三", 901L, 801L,
|
|
|
|
|
"SOURCE_COMPLETE_CURRENCY", "CONTROL_BIT", "CONTROL_SIGNATURE", "SOURCE_COMPLETE_CURRENCY",
|
|
|
|
|
"COIN_SIGNATURE", "SOURCE_COMPLETE_CURRENCY|COIN_SIGNATURE", Instant.now(), "user-1", "张三");
|
|
|
|
|
DigitalCurrencyProductionBatch batch = new DigitalCurrencyProductionBatch("MINT_001", requestId, "RESERVE_001",
|
|
|
|
|
"ORG_001", "DC", new BigDecimal("100.00"), "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三",
|
|
|
|
|
81L, 71L, "CONTROL_BIT", "CONTROL_SIGNATURE", Collections.singletonList(coin));
|
|
|
|
|
String confirmationText = confirmationText(requestId, "100.00", "DC_001");
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation central = new DigitalCurrencyOwnershipConfirmation(requestId, "MINT_001",
|
|
|
|
|
"CENTRAL_CONFIRMED", Instant.now(), "user-1", "张三", InstitutionKeyService.CENTRAL_FIRST_KEY,
|
|
|
|
|
confirmationText, "BATCH_DIGEST", "CENTRAL_SIGNATURE",
|
|
|
|
|
null, null, null, null, null, null, null, null);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation verified = central.verified(Instant.now(), "user-1", "张三");
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation activated = verified.currenciesActivated();
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(batch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId))
|
|
|
|
|
.thenReturn(Optional.of(central), Optional.of(verified), Optional.of(activated));
|
|
|
|
|
when(notificationRepository.findByRequestId(requestId)).thenReturn(Optional.of(notification(requestId)));
|
|
|
|
|
when(gateway.digest(confirmationText)).thenReturn("BATCH_DIGEST");
|
|
|
|
|
when(gateway.verifyOwnership(subject, "BATCH_DIGEST", "CENTRAL_SIGNATURE")).thenReturn(true);
|
|
|
|
|
when(gateway.verifyOwnership(subject, "SOURCE_COMPLETE_CURRENCY", "COIN_SIGNATURE")).thenReturn(true);
|
|
|
|
|
when(gateway.digest(org.mockito.ArgumentMatchers.startsWith("OWNERSHIP_RECEIPT|")))
|
|
|
|
|
.thenReturn("RECEIPT_DIGEST");
|
|
|
|
|
when(gateway.signReceipt(subject, "RECEIPT_DIGEST")).thenReturn("RECEIPT_SIGNATURE");
|
|
|
|
|
when(gateway.commercialBankSigningKeyId()).thenReturn(InstitutionKeyService.BANK_SECOND_KEY);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service =
|
|
|
|
|
new DigitalCurrencyOwnershipConfirmationService(repository, notificationRepository, gateway);
|
|
|
|
|
|
|
|
|
|
service.verifyCentralBankConfirmation(requestId, actor, subject);
|
|
|
|
|
service.activateCurrencies(requestId, actor, subject);
|
|
|
|
|
DigitalCurrencyProductionBatchView result = service.signReceipt(requestId, actor, subject);
|
|
|
|
|
|
|
|
|
|
assertThat(result.getStatus()).isEqualTo("OWNERSHIP_CONFIRMED");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getStatus()).isEqualTo("RECEIPT_SENT");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getReceiptDigest()).isEqualTo("RECEIPT_DIGEST");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getReceiptSignature()).isEqualTo("RECEIPT_SIGNATURE");
|
|
|
|
|
assertThat(result.getOwnershipConfirmation().getReceiptSigningKeyId()).isEqualTo(InstitutionKeyService.BANK_SECOND_KEY);
|
|
|
|
|
verify(gateway).activateGeneratedCurrencies(subject, requestId, "BK01", "ORG_001",
|
|
|
|
|
Collections.singletonList(coin), actor);
|
|
|
|
|
ArgumentCaptor<DigitalCurrencyOwnershipConfirmation> stateCaptor =
|
|
|
|
|
ArgumentCaptor.forClass(DigitalCurrencyOwnershipConfirmation.class);
|
|
|
|
|
verify(repository, times(3)).confirmOwnership(org.mockito.ArgumentMatchers.any(DigitalCurrencyProductionBatch.class),
|
|
|
|
|
stateCaptor.capture());
|
|
|
|
|
assertThat(stateCaptor.getAllValues()).extracting(DigitalCurrencyOwnershipConfirmation::getStatus)
|
|
|
|
|
.containsExactly("BANK_VERIFIED", "CURRENCIES_ACTIVATED", "RECEIPT_SENT");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void rejectsActivationWhenTheCommercialBankCannotVerifyTheCentralBankConfirmation() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
ReserveDeductionNotificationRepository notificationRepository = mock(ReserveDeductionNotificationRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DraftDigitalCurrency coin = new DraftDigitalCurrency("DC_001", "MINT_001", 1, new BigDecimal("100.00"),
|
|
|
|
|
"ORG_001", "DC", "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三", 901L, 801L,
|
|
|
|
|
"SOURCE_COMPLETE_CURRENCY", "CONTROL_BIT", "CONTROL_SIGNATURE", "SOURCE_COMPLETE_CURRENCY",
|
|
|
|
|
"COIN_SIGNATURE", "SOURCE_COMPLETE_CURRENCY|COIN_SIGNATURE", Instant.now(), "user-1", "张三");
|
|
|
|
|
DigitalCurrencyProductionBatch batch = new DigitalCurrencyProductionBatch("MINT_001", requestId, "RESERVE_001",
|
|
|
|
|
"ORG_001", "DC", new BigDecimal("100.00"), "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三",
|
|
|
|
|
81L, 71L, "CONTROL_BIT", "CONTROL_SIGNATURE", Collections.singletonList(coin));
|
|
|
|
|
String confirmationText = confirmationText(requestId, "100.00", "DC_001");
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation central = new DigitalCurrencyOwnershipConfirmation(requestId, "MINT_001",
|
|
|
|
|
"CENTRAL_CONFIRMED", Instant.now(), "user-1", "张三", InstitutionKeyService.CENTRAL_FIRST_KEY,
|
|
|
|
|
confirmationText, "BATCH_DIGEST", "TAMPERED_SIGNATURE",
|
|
|
|
|
null, null, null, null, null, null, null, null);
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(batch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId)).thenReturn(Optional.of(central));
|
|
|
|
|
when(gateway.digest(confirmationText)).thenReturn("BATCH_DIGEST");
|
|
|
|
|
when(gateway.verifyOwnership(subject, "BATCH_DIGEST", "TAMPERED_SIGNATURE")).thenReturn(false);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service =
|
|
|
|
|
new DigitalCurrencyOwnershipConfirmationService(repository, notificationRepository, gateway);
|
|
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> service.verifyCentralBankConfirmation(requestId, actor, subject))
|
|
|
|
|
.isInstanceOf(RuntimeException.class);
|
|
|
|
|
assertThatThrownBy(() -> service.activateCurrencies(requestId, actor, subject))
|
|
|
|
|
.isInstanceOf(RuntimeException.class);
|
|
|
|
|
verify(gateway, never()).activateGeneratedCurrencies(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.anyString(),
|
|
|
|
|
org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyList(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void rejectsCentralConfirmationWhenTheSignedBatchOriginalTextWasTampered() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DigitalCurrencyProductionBatch batch = signedBatch(requestId, "100.00",
|
|
|
|
|
Collections.singletonList(signedCoin("DC_001")));
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation central = centralConfirmation(requestId,
|
|
|
|
|
confirmationText(requestId, "100.00", "DC_001") + "|TAMPERED");
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(batch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId)).thenReturn(Optional.of(central));
|
|
|
|
|
when(gateway.verifyOwnership(subject, "BATCH_DIGEST", "CENTRAL_SIGNATURE")).thenReturn(true);
|
|
|
|
|
when(gateway.verifyOwnership(subject, "SOURCE_COMPLETE_CURRENCY", "COIN_SIGNATURE")).thenReturn(true);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service = new DigitalCurrencyOwnershipConfirmationService(
|
|
|
|
|
repository, mock(ReserveDeductionNotificationRepository.class), gateway);
|
|
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> service.verifyCentralBankConfirmation(requestId, actor, subject))
|
|
|
|
|
.isInstanceOf(RuntimeException.class);
|
|
|
|
|
verify(repository, never()).confirmOwnership(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void rejectsCentralConfirmationWhenBatchMetadataChangedAfterSigning() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DigitalCurrencyProductionBatch changedBatch = signedBatch(requestId, "200.00",
|
|
|
|
|
Collections.singletonList(signedCoin("DC_001")));
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation central = centralConfirmation(requestId,
|
|
|
|
|
confirmationText(requestId, "100.00", "DC_001"));
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(changedBatch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId)).thenReturn(Optional.of(central));
|
|
|
|
|
when(gateway.verifyOwnership(subject, "BATCH_DIGEST", "CENTRAL_SIGNATURE")).thenReturn(true);
|
|
|
|
|
when(gateway.verifyOwnership(subject, "SOURCE_COMPLETE_CURRENCY", "COIN_SIGNATURE")).thenReturn(true);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service = new DigitalCurrencyOwnershipConfirmationService(
|
|
|
|
|
repository, mock(ReserveDeductionNotificationRepository.class),
|
|
|
|
|
gateway);
|
|
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> service.verifyCentralBankConfirmation(requestId, actor, subject))
|
|
|
|
|
.isInstanceOf(RuntimeException.class);
|
|
|
|
|
verify(repository, never()).confirmOwnership(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void rejectsCentralConfirmationWhenCoinMembershipChangedAfterSigning() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DigitalCurrencyProductionBatch changedBatch = signedBatch(requestId, "100.00",
|
|
|
|
|
Collections.singletonList(signedCoin("DC_002")));
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation central = centralConfirmation(requestId,
|
|
|
|
|
confirmationText(requestId, "100.00", "DC_001"));
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(changedBatch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId)).thenReturn(Optional.of(central));
|
|
|
|
|
when(gateway.verifyOwnership(subject, "BATCH_DIGEST", "CENTRAL_SIGNATURE")).thenReturn(true);
|
|
|
|
|
when(gateway.verifyOwnership(subject, "SOURCE_COMPLETE_CURRENCY", "COIN_SIGNATURE")).thenReturn(true);
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service = new DigitalCurrencyOwnershipConfirmationService(
|
|
|
|
|
repository, mock(ReserveDeductionNotificationRepository.class),
|
|
|
|
|
gateway);
|
|
|
|
|
|
|
|
|
|
assertThatThrownBy(() -> service.verifyCentralBankConfirmation(requestId, actor, subject))
|
|
|
|
|
.isInstanceOf(RuntimeException.class);
|
|
|
|
|
verify(repository, never()).confirmOwnership(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
void treatsLegacyConfirmedOwnershipAsAnAlreadyCompletedTerminalResult() {
|
|
|
|
|
UUID requestId = UUID.randomUUID();
|
|
|
|
|
DigitalCurrencyProductionRepository repository = mock(DigitalCurrencyProductionRepository.class);
|
|
|
|
|
DigitalCurrencyGenerationModuleGateway gateway = mock(DigitalCurrencyGenerationModuleGateway.class);
|
|
|
|
|
DigitalCurrencyProductionBatch batch = new DigitalCurrencyProductionBatch("MINT_001", requestId, "RESERVE_001",
|
|
|
|
|
"ORG_001", "DC", new BigDecimal("100.00"), "OWNERSHIP_CONFIRMED", Instant.now(), "user-1", "张三",
|
|
|
|
|
81L, 71L, "CONTROL_BIT", "CONTROL_SIGNATURE", Collections.singletonList(signedCoin("DC_001")));
|
|
|
|
|
DigitalCurrencyOwnershipConfirmation legacy = new DigitalCurrencyOwnershipConfirmation(requestId, "MINT_001",
|
|
|
|
|
"CONFIRMED", Instant.now(), "user-1", "张三", InstitutionKeyService.CENTRAL_FIRST_KEY);
|
|
|
|
|
when(repository.findByRequestId(requestId)).thenReturn(Optional.of(batch));
|
|
|
|
|
when(repository.findOwnershipConfirmationByRequestId(requestId)).thenReturn(Optional.of(legacy));
|
|
|
|
|
DigitalCurrencyOwnershipConfirmationService service = new DigitalCurrencyOwnershipConfirmationService(
|
|
|
|
|
repository, mock(ReserveDeductionNotificationRepository.class), gateway);
|
|
|
|
|
|
|
|
|
|
assertThat(service.confirm(requestId, actor, subject).getOwnershipConfirmation().getStatus()).isEqualTo("CONFIRMED");
|
|
|
|
|
assertThat(service.verifyCentralBankConfirmation(requestId, actor, subject)
|
|
|
|
|
.getOwnershipConfirmation().getStatus()).isEqualTo("CONFIRMED");
|
|
|
|
|
assertThat(service.activateCurrencies(requestId, actor, subject)
|
|
|
|
|
.getOwnershipConfirmation().getStatus()).isEqualTo("CONFIRMED");
|
|
|
|
|
assertThat(service.signReceipt(requestId, actor, subject)
|
|
|
|
|
.getOwnershipConfirmation().getStatus()).isEqualTo("CONFIRMED");
|
|
|
|
|
verify(repository, never()).confirmOwnership(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
verify(gateway, never()).activateGeneratedCurrencies(org.mockito.ArgumentMatchers.any(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any(), org.mockito.ArgumentMatchers.anyString(),
|
|
|
|
|
org.mockito.ArgumentMatchers.anyString(), org.mockito.ArgumentMatchers.anyList(),
|
|
|
|
|
org.mockito.ArgumentMatchers.any());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DraftDigitalCurrency signedCoin(String coinId) {
|
|
|
|
|
return new DraftDigitalCurrency(coinId, "MINT_001", 1, new BigDecimal("100.00"),
|
|
|
|
|
"ORG_001", "DC", "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三", 901L, 801L,
|
|
|
|
|
"SOURCE_COMPLETE_CURRENCY", "CONTROL_BIT", "CONTROL_SIGNATURE", "SOURCE_COMPLETE_CURRENCY",
|
|
|
|
|
"COIN_SIGNATURE", "SOURCE_COMPLETE_CURRENCY|COIN_SIGNATURE", Instant.now(), "user-1", "张三");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DigitalCurrencyProductionBatch signedBatch(UUID requestId, String totalAmount,
|
|
|
|
|
java.util.List<DraftDigitalCurrency> coins) {
|
|
|
|
|
return new DigitalCurrencyProductionBatch("MINT_001", requestId, "RESERVE_001", "ORG_001", "DC",
|
|
|
|
|
new BigDecimal(totalAmount), "OWNERSHIP_SIGNED", Instant.now(), "user-1", "张三",
|
|
|
|
|
81L, 71L, "CONTROL_BIT", "CONTROL_SIGNATURE", coins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DigitalCurrencyOwnershipConfirmation centralConfirmation(UUID requestId, String originalText) {
|
|
|
|
|
return new DigitalCurrencyOwnershipConfirmation(requestId, "MINT_001", "CENTRAL_CONFIRMED", Instant.now(),
|
|
|
|
|
"user-1", "张三", InstitutionKeyService.CENTRAL_FIRST_KEY, originalText, "BATCH_DIGEST",
|
|
|
|
|
"CENTRAL_SIGNATURE", null, null, null, null, null, null, null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String confirmationText(UUID requestId, String totalAmount, String coinId) {
|
|
|
|
|
return "OWNERSHIP_CONFIRM|" + requestId + "|MINT_001|ORG_001|DC|" + totalAmount
|
|
|
|
|
+ "|1:" + coinId + ":COIN_SIGNATURE";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private CentralBankIssuanceReceipt receipt(UUID requestId) {
|
|
|
|
|
return new CentralBankIssuanceReceipt(requestId, "ISSUE_REQ_1",
|
|
|
|
|
"{\"orgId\":\"ORG_001\",\"currency\":\"DC\",\"totalAmount\":\"100.00\","
|
|
|
|
|
|