Skip to content

Commit 7c38798

Browse files
committed
rename secret santa
1 parent 59c4e6a commit 7c38798

File tree

78 files changed

+153
-20947
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+153
-20947
lines changed

Advanced/negotiation-cordapp/build.gradle

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44

55
ext {
66
corda_release_group = constants.getProperty("cordaReleaseGroup")
7-
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
7+
corda_core_release_group = constants.getProperty("cordaCoreReleaseGroup")
88
corda_release_version = constants.getProperty("cordaVersion")
99
corda_core_release_version = constants.getProperty("cordaCoreVersion")
1010
corda_gradle_plugins_version = constants.getProperty("gradlePluginsVersion")
@@ -107,29 +107,16 @@ cordapp {
107107
}
108108
}
109109

110-
task ganache {
111-
subprojects {
112-
if (it.project.name != "clients") {
113-
dependsOn jar
114-
doLast {
115-
copy {
116-
from "${buildDir}/libs"
117-
into "${rootDir}/build/libs"
118-
}
119-
}
120-
}
121-
}
122-
}
123-
124110
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
125-
nodeDefaults {
126111

112+
nodeDefaults {
127113
cordapp project(':contracts')
128-
runSchemaMigration = true
114+
runSchemaMigration = true
129115
}
116+
130117
node {
131118
name "O=Notary,L=London,C=GB"
132-
notary = [validating : false]
119+
notary = [validating: false]
133120
p2pPort 10002
134121
rpcSettings {
135122
address("localhost:10003")
@@ -143,7 +130,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
143130
address("localhost:10006")
144131
adminAddress("localhost:10046")
145132
}
146-
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
133+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
147134
}
148135
node {
149136
name "O=PartyB,L=New York,C=US"
@@ -152,7 +139,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
152139
address("localhost:10009")
153140
adminAddress("localhost:10049")
154141
}
155-
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
142+
rpcUsers = [[user: "user1", "password": "test", "permissions": ["ALL"]]]
156143
}
157144
}
158145

Advanced/negotiation-cordapp/contracts/src/main/java/net/corda/samples/negotiation/contracts/ProposalAndTradeContract.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
import static net.corda.core.contracts.ContractsDSL.requireThat;
1212

1313
public class ProposalAndTradeContract implements Contract {
14-
public static String ID = "ProposalAndTradeContract";
14+
public static String ID = "net.corda.samples.negotiation.contracts.ProposalAndTradeContract";
15+
1516
@Override
1617
public void verify(LedgerTransaction tx) throws IllegalArgumentException {
1718
final CommandWithParties command = tx.getCommands().get(0);
1819

19-
if( command.getValue() instanceof Commands.Propose) {
20+
if (command.getValue() instanceof Commands.Propose) {
2021
requireThat(require -> {
2122
require.using("There are no inputs", tx.getInputs().isEmpty());
2223
require.using("Only one output state should be created.", tx.getOutputs().size() == 1);
@@ -29,7 +30,7 @@ public void verify(LedgerTransaction tx) throws IllegalArgumentException {
2930
require.using("The proposee is a required signer", command.getSigners().contains(output.getProposee().getOwningKey()));
3031
return null;
3132
});
32-
}else if(command.getValue() instanceof Commands.Accept){
33+
} else if (command.getValue() instanceof Commands.Accept) {
3334
requireThat(require -> {
3435
require.using("There is exactly one input", tx.getInputStates().size() == 1);
3536
require.using("The single input is of type ProposalState", tx.inputsOfType(ProposalState.class).size() == 1);
@@ -49,8 +50,8 @@ public void verify(LedgerTransaction tx) throws IllegalArgumentException {
4950
require.using("The proposee is a required signer", command.getSigners().contains(input.getProposee().getOwningKey()));
5051
return null;
5152
});
52-
}else if(command.getValue() instanceof Commands.Modify){
53-
requireThat(require ->{
53+
} else if (command.getValue() instanceof Commands.Modify) {
54+
requireThat(require -> {
5455
require.using("There is exactly one input", tx.getInputStates().size() == 1);
5556
require.using("The single input is of type ProposalState", tx.inputsOfType(ProposalState.class).size() == 1);
5657
require.using("There is exactly one output", tx.getOutputs().size() == 1);
@@ -70,16 +71,27 @@ public void verify(LedgerTransaction tx) throws IllegalArgumentException {
7071
return null;
7172

7273
});
73-
}else{
74+
} else {
7475
throw new IllegalArgumentException("Command of incorrect type");
7576
}
7677

7778
}
7879

7980

8081
public interface Commands extends CommandData {
81-
class Propose implements Commands{};
82-
class Accept implements Commands{};
83-
class Modify implements Commands{};
82+
class Propose implements Commands {
83+
}
84+
85+
;
86+
87+
class Accept implements Commands {
88+
}
89+
90+
;
91+
92+
class Modify implements Commands {
93+
}
94+
95+
;
8496
}
8597
}

Advanced/negotiation-cordapp/contracts/src/main/java/net/corda/samples/negotiation/states/ProposalState.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package net.corda.samples.negotiation.states;
22

33
import com.google.common.collect.ImmutableList;
4-
import net.corda.samples.negotiation.contracts.ProposalAndTradeContract;
4+
55
import net.corda.core.contracts.BelongsToContract;
66
import net.corda.core.contracts.LinearState;
77
import net.corda.core.contracts.UniqueIdentifier;
88
import net.corda.core.identity.AbstractParty;
99
import net.corda.core.identity.Party;
1010
import net.corda.core.serialization.ConstructorForDeserialization;
11+
import net.corda.samples.negotiation.contracts.ProposalAndTradeContract;
1112
import org.jetbrains.annotations.NotNull;
1213

1314
import java.util.List;
@@ -66,8 +67,7 @@ public UniqueIdentifier getLinearId() {
6667

6768
@NotNull
6869
@Override
69-
public List<AbstractParty> getParticipants(){
70+
public List<AbstractParty> getParticipants() {
7071
return ImmutableList.of(proposer, proposee);
71-
7272
}
7373
}

Advanced/negotiation-cordapp/contracts/src/main/java/net/corda/samples/negotiation/states/TradeState.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public UniqueIdentifier getLinearId() {
5151

5252
@Override
5353
public List<AbstractParty> getParticipants() {
54-
return ImmutableList.of(buyer,seller);
54+
return ImmutableList.of(buyer, seller);
5555
}
5656
}

Advanced/negotiation-cordapp/contracts/src/test/java/net/corda/samples/negotiation/contracts/AcceptanceContractTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class AcceptanceContractTests {
1616

17-
private MockServices ledgerServices = new MockServices(ImmutableList.of("negotiation.contracts"));
17+
private MockServices ledgerServices = new MockServices(ImmutableList.of("net.corda.samples.negotiation.contracts"));
1818
private TestIdentity alice = new TestIdentity(new net.corda.core.identity.CordaX500Name("alice","New York", "US"));
1919
private TestIdentity bob = new TestIdentity(new net.corda.core.identity.CordaX500Name("bob","Tokyo", "JP"));
2020
private TestIdentity charlie = new TestIdentity(new net.corda.core.identity.CordaX500Name("charlie","London", "GB"));

Advanced/negotiation-cordapp/contracts/src/test/java/net/corda/samples/negotiation/contracts/ModificationContractTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class ModificationContractTests {
1616

17-
private MockServices ledgerServices = new MockServices(ImmutableList.of("negotiation.contracts"));
17+
private MockServices ledgerServices = new MockServices(ImmutableList.of("net.corda.samples.negotiation.contracts"));
1818
private TestIdentity alice = new TestIdentity(new net.corda.core.identity.CordaX500Name("alice","New York", "US"));
1919
private TestIdentity bob = new TestIdentity(new net.corda.core.identity.CordaX500Name("bob","Tokyo", "JP"));
2020
private TestIdentity charlie = new TestIdentity(new net.corda.core.identity.CordaX500Name("charlie","London", "GB"));

Advanced/negotiation-cordapp/contracts/src/test/java/net/corda/samples/negotiation/contracts/ProposalContractTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
public class ProposalContractTests {
1717

18-
private MockServices ledgerServices = new MockServices(ImmutableList.of("negotiation.contracts"));
18+
private MockServices ledgerServices = new MockServices(ImmutableList.of("net.corda.samples.negotiation.contracts"));
1919
private TestIdentity alice = new TestIdentity(new net.corda.core.identity.CordaX500Name("alice","New York", "US"));
2020
private TestIdentity bob = new TestIdentity(new net.corda.core.identity.CordaX500Name("bob","Tokyo", "JP"));
2121
private TestIdentity charlie = new TestIdentity(new net.corda.core.identity.CordaX500Name("charlie","London", "GB"));
Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,57 @@
11
package net.corda.samples.negotiation.states;
2-
//TODO
3-
public class ProposalStateTest {
2+
3+
import net.corda.core.contracts.UniqueIdentifier;
4+
import net.corda.core.identity.CordaX500Name;
5+
import net.corda.core.identity.Party;
6+
import net.corda.testing.core.TestIdentity;
7+
import org.junit.Test;
8+
9+
import static junit.framework.TestCase.assertEquals;
10+
import static org.junit.Assert.*;
11+
12+
13+
public class ProposalStateTests {
14+
15+
private int amount = 10;
16+
private final Party proposer = new TestIdentity(new CordaX500Name("Alice", "", "GB")).getParty();
17+
private final Party buyer = new TestIdentity(new CordaX500Name("Bob", "", "GB")).getParty();
18+
private final Party seller = new TestIdentity(new CordaX500Name("Charlie", "", "GB")).getParty();
19+
private final Party proposee = new TestIdentity(new CordaX500Name("Dan", "", "GB")).getParty();
20+
21+
@Test
22+
public void constructorTest() {
23+
24+
UniqueIdentifier tempId = new UniqueIdentifier();
25+
ProposalState ps = new ProposalState(amount, buyer, seller, proposer, proposee, tempId);
26+
27+
assertEquals(ps.getAmount(), amount);
28+
assertEquals(ps.getBuyer(), buyer);
29+
assertEquals(ps.getSeller(), seller);
30+
assertEquals(ps.getProposer(), proposer);
31+
assertEquals(ps.getProposee(), proposee);
32+
assertEquals(ps.getLinearId(), tempId);
33+
34+
assertNotEquals(ps.getAmount(), 0);
35+
assertNotEquals(ps.getAmount(), -5);
36+
assertNotEquals(ps.getAmount(), null);
37+
}
38+
39+
@Test
40+
public void linearIdTest() {
41+
ProposalState ps = new ProposalState(amount, buyer, seller, proposer, proposee);
42+
43+
// ensure ID is generated with shorter constructor stub
44+
assertTrue(ps.getLinearId() instanceof UniqueIdentifier);
45+
}
46+
47+
@Test
48+
public void participantTest() {
49+
ProposalState ps = new ProposalState(amount, buyer, seller, proposer, proposee);
50+
51+
// ensure participants are generated correctly
52+
assertTrue(ps.getParticipants().contains(proposer));
53+
assertTrue(ps.getParticipants().contains(proposee));
54+
assertFalse(ps.getParticipants().contains(buyer));
55+
assertFalse(ps.getParticipants().contains(seller));
56+
}
457
}
Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
11
package net.corda.samples.negotiation.states;
2-
//TODO
3-
public class TradeStateTest {
2+
3+
import net.corda.core.contracts.UniqueIdentifier;
4+
import net.corda.core.identity.CordaX500Name;
5+
import net.corda.core.identity.Party;
6+
import net.corda.testing.core.TestIdentity;
7+
import org.junit.Test;
8+
9+
import static junit.framework.TestCase.assertEquals;
10+
import static org.junit.Assert.*;
11+
12+
13+
public class TradeStateTests {
14+
15+
private int amount = 10;
16+
private final Party buyer = new TestIdentity(new CordaX500Name("Bob", "", "GB")).getParty();
17+
private final Party seller = new TestIdentity(new CordaX500Name("Charlie", "", "GB")).getParty();
18+
19+
@Test
20+
public void constructorTest() {
21+
22+
UniqueIdentifier tempId = new UniqueIdentifier();
23+
TradeState ts = new TradeState(amount, buyer, seller, tempId);
24+
25+
assertEquals(ts.getAmount(), amount);
26+
assertEquals(ts.getBuyer(), buyer);
27+
assertEquals(ts.getSeller(), seller);
28+
assertEquals(ts.getLinearId(), tempId);
29+
30+
assertNotEquals(ts.getAmount(), 0);
31+
assertNotEquals(ts.getAmount(), -5);
32+
assertNotEquals(ts.getAmount(), null);
33+
}
34+
35+
@Test
36+
public void linearIdTest() {
37+
TradeState ts = new TradeState(amount, buyer, seller);
38+
39+
// ensure ID is generated with shorter constructor stub
40+
assertTrue(ts.getLinearId() instanceof UniqueIdentifier);
41+
}
42+
43+
@Test
44+
public void participantTest() {
45+
TradeState ts = new TradeState(amount, buyer, seller);
46+
47+
// ensure participants are generated correctly
48+
assertTrue(ts.getParticipants().contains(buyer));
49+
assertTrue(ts.getParticipants().contains(seller));
50+
}
51+
452
}

Advanced/negotiation-cordapp/workflows/src/test/java/net/corda/samples/negotiation/flows/AcceptanceFlowTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import java.util.concurrent.ExecutionException;
1414
import java.util.concurrent.Future;
1515

16-
public class AcceptanceFlowTests extends FlowTestsBase{
16+
public class AcceptanceFlowTests extends FlowTestBase {
1717

1818
@Test
1919
public void acceptanceFlowConsumesTheProposalsInBothNodesVaultsAndReplacesWithEquivAccTradesWhenInitiatorIsBuyer() throws ExecutionException, InterruptedException {
@@ -43,7 +43,7 @@ private void testAcceptance(Boolean isBuyer) throws ExecutionException, Interrup
4343
Party counterparty = b.getInfo().getLegalIdentitiesAndCerts().get(0).getParty();
4444
UniqueIdentifier proposalId = nodeACreatesProposal(isBuyer, amount, counterparty);
4545
nodeBAcceptsProposal(proposalId);
46-
ImmutableList.of(a,b).forEach(node -> {
46+
ImmutableList.of(a, b).forEach(node -> {
4747
node.transaction(() -> {
4848
List<StateAndRef<ProposalState>> proposals = node.getServices().getVaultService().queryBy(ProposalState.class).getStates();
4949
Assert.assertEquals(0, proposals.size());
@@ -56,10 +56,10 @@ private void testAcceptance(Boolean isBuyer) throws ExecutionException, Interrup
5656
Party buyer;
5757
Party seller;
5858

59-
if(isBuyer){
59+
if (isBuyer) {
6060
buyer = a.getInfo().getLegalIdentitiesAndCerts().get(0).getParty();
6161
seller = b.getInfo().getLegalIdentitiesAndCerts().get(0).getParty();
62-
}else{
62+
} else {
6363
seller = a.getInfo().getLegalIdentitiesAndCerts().get(0).getParty();
6464
buyer = b.getInfo().getLegalIdentitiesAndCerts().get(0).getParty();
6565
}

0 commit comments

Comments
 (0)