Skip to content
Snippets Groups Projects
Commit c12571e6 authored by Benoit Lavenier's avatar Benoit Lavenier
Browse files

[enh] Add unit test for multi dest transfer

parent e67cac73
No related branches found
No related tags found
No related merge requests found
Pipeline #15529 failed
......@@ -3,7 +3,7 @@
<parent>
<artifactId>duniter4j</artifactId>
<groupId>org.duniter</groupId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
......
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.duniter</groupId>
<artifactId>duniter4j</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<artifactId>duniter4j-core-client</artifactId>
......
......@@ -72,6 +72,8 @@ public interface TransactionRemoteService extends Service {
String transfer(Wallet wallet, String destPubKey, long amount,
String comment) throws InsufficientCreditException;
String transfer(Wallet wallet, Map<String,Long> mapPubkeyAmount, String comment) throws InsufficientCreditException;
TxSource getSources(Peer peer, String pubKey);
TxSource getSources(String currencyId, String pubKey);
......
......@@ -87,6 +87,10 @@ public class TransactionRemoteServiceImpl extends BaseRemoteServiceImpl implemen
return transfer(null, wallet, destPubKey, amount, comment);
}
@Override
public String transfer(Wallet wallet, Map<String, Long> mapPubkeyAmount, String comment) throws InsufficientCreditException {
return transfer(null, wallet, mapPubkeyAmount, comment);
}
public String transfer(Peer peer, Wallet wallet, String destPubKey, long amount,
String comment) throws InsufficientCreditException {
......
......@@ -23,6 +23,9 @@ package org.duniter.core.client.service.bma;
*/
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.duniter.core.client.TestResource;
import org.duniter.core.client.config.Configuration;
import org.duniter.core.client.model.bma.TxSource;
......@@ -35,12 +38,12 @@ import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
import java.util.Objects;
@Slf4j
public class TransactionRemoteServiceTest {
private static final Logger log = LoggerFactory.getLogger(TransactionRemoteServiceTest.class);
@ClassRule
public static final TestResource resource = TestResource.create();
......@@ -62,7 +65,7 @@ public class TransactionRemoteServiceTest {
try {
service.transfer(
createTestWallet(),
resource.getFixtures().getOtherUserPublicKey(),
resource.getFixtures().getOtherUserPublicKey(0),
1,
"my comments" + System.currentTimeMillis());
} catch (InsufficientCreditException e) {
......@@ -70,6 +73,24 @@ public class TransactionRemoteServiceTest {
}
}
@Test
public void transferMulti() throws Exception {
Map<String, Long> destPubkeyAmount = ImmutableMap.<String, Long>builder()
.put(resource.getFixtures().getOtherUserPublicKey(0), 1l)
.put(resource.getFixtures().getOtherUserPublicKey(1), 2l)
.build();
try {
service.transfer(
createTestWallet(),
destPubkeyAmount,
"my comments" + System.currentTimeMillis());
} catch (InsufficientCreditException e) {
// OK continue
}
}
@Test
public void getSources() throws Exception {
......
duniter4j.node.host=g1-test.duniter.org
duniter4j.node.port=10900
duniter4j.node.elasticsearch.host=localhost
duniter4j.node.elasticsearch.port=9200
duniter4j.node.elasticsearch.host=g1-test.data.e-is.pro
duniter4j.node.elasticsearch.port=80
......@@ -5,7 +5,7 @@
<parent>
<groupId>org.duniter</groupId>
<artifactId>duniter4j</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
</parent>
<artifactId>duniter4j-core-shared</artifactId>
......
......@@ -85,9 +85,16 @@ public class TestFixtures {
* Get a public key of another user, encode in base 58.
* @return
*/
public String getOtherUserPublicKey() {
public String getOtherUserPublicKey(int index) {
switch (index) {
case 0:
default:
// = kimamila
return "5ocqzyDMMWf1V8bsoNhWb1iNwax1e9M7VTUN6navs8of";
case 1:
// = ji_emme_test
return "BubEHcMEAkC5trxru2D9GAkRsdFbLMQ1Mbgya5ZyndN7";
}
}
}
......@@ -5,7 +5,7 @@
<groupId>org.duniter</groupId>
<artifactId>duniter4j</artifactId>
<version>1.5.1-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Duniter4j</name>
<description>a Duniter Java Client API</description>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment