Skip to content

Commit d48633e

Browse files
committed
update notart selection Features
1 parent a306e4a commit d48633e

File tree

36 files changed

+108
-174
lines changed

36 files changed

+108
-174
lines changed

Features/attachment-blacklist/workflows/src/main/java/net/corda/samples/blacklist/ProposeFlow.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.common.collect.ImmutableSet;
55
import net.corda.core.crypto.SecureHash;
66
import net.corda.core.flows.*;
7+
import net.corda.core.identity.CordaX500Name;
78
import net.corda.core.identity.Party;
89
import net.corda.core.transactions.SignedTransaction;
910
import net.corda.core.transactions.TransactionBuilder;
@@ -42,13 +43,8 @@ Party getFirstNotary() throws FlowException {
4243
public SignedTransaction call() throws FlowException {
4344

4445
// Obtain a reference to a notary we wish to use.
45-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
46-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
47-
*
48-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
49-
*/
50-
Party notary = getFirstNotary(); // METHOD 1
51-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
46+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
47+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
5248

5349
AgreementState agreementState = new AgreementState(getOurIdentity(), counterparty, agreementTxt);
5450
AgreementContract.Commands.Agree agreeCmd = new AgreementContract.Commands.Agree();

Features/attachment-blacklist/workflows/src/test/java/net/corda/samples/blacklist/FlowTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
import net.corda.core.contracts.StateAndRef;
77
import net.corda.core.contracts.TransactionVerificationException;
88
import net.corda.core.crypto.SecureHash;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.core.identity.Party;
1011
import net.corda.core.transactions.SignedTransaction;
1112
import net.corda.samples.blacklist.states.AgreementState;
12-
import net.corda.testing.node.MockNetwork;
13-
import net.corda.testing.node.MockNetworkParameters;
14-
import net.corda.testing.node.StartedMockNode;
15-
import net.corda.testing.node.TestCordapp;
13+
import net.corda.testing.node.*;
1614
import org.hamcrest.core.IsInstanceOf;
1715
import org.junit.After;
1816
import org.junit.Before;
@@ -43,7 +41,9 @@ public class FlowTests {
4341
@Before
4442
public void setup() throws FileNotFoundException {
4543
this.network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(ImmutableList.of(
46-
TestCordapp.findCordapp("net.corda.samples.blacklist.contracts"))));
44+
TestCordapp.findCordapp("net.corda.samples.blacklist.contracts")))
45+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
46+
);
4747
this.a = this.network.createNode();
4848
this.b = this.network.createNode();
4949
this.aIdentity = this.a.getInfo().getLegalIdentities().get(0);
778 KB
Binary file not shown.

Features/attachment-sendfile/workflows/src/main/java/net/corda/samples/sendfile/flows/SendAttachment.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.google.common.collect.ImmutableList;
55
import net.corda.core.crypto.SecureHash;
66
import net.corda.core.flows.*;
7+
import net.corda.core.identity.CordaX500Name;
78
import net.corda.core.identity.Party;
89
import net.corda.core.node.ServiceHub;
910
import net.corda.core.transactions.SignedTransaction;
@@ -53,14 +54,8 @@ public ProgressTracker getProgressTracker() {
5354
public SignedTransaction call() throws FlowException {
5455

5556
// Obtain a reference to a notary we wish to use.
56-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
57-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
58-
*
59-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
60-
*/
61-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
62-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
63-
57+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
58+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
6459
// Initiate transaction Builder
6560
TransactionBuilder transactionBuilder = new TransactionBuilder(notary);
6661

Features/attachment-sendfile/workflows/src/test/java/net/corda/samples/sendfile/flows/FlowTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.concurrent.CordaFuture;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.core.transactions.SignedTransaction;
6-
import net.corda.testing.node.MockNetwork;
7-
import net.corda.testing.node.MockNetworkParameters;
8-
import net.corda.testing.node.StartedMockNode;
9-
import net.corda.testing.node.TestCordapp;
7+
import net.corda.testing.node.*;
108
import org.junit.After;
119
import org.junit.Before;
1210
import org.junit.Test;
@@ -17,7 +15,8 @@ public class FlowTests {
1715
private final MockNetwork network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(ImmutableList.of(
1816
TestCordapp.findCordapp("net.corda.samples.sendfile.contracts"),
1917
TestCordapp.findCordapp("net.corda.samples.sendfile.flows")
20-
)));
18+
))
19+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB")))));
2120
private final StartedMockNode a = network.createNode();
2221
private final StartedMockNode b = network.createNode();
2322

Features/confidentialidentity-whistleblower/workflows/src/main/java/net/corda/samples/whistleblower/flows/BlowWhistleFlow.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import net.corda.core.contracts.CommandData;
77
import net.corda.core.flows.*;
88
import net.corda.core.identity.AnonymousParty;
9+
import net.corda.core.identity.CordaX500Name;
910
import net.corda.core.identity.Party;
1011
import net.corda.core.transactions.SignedTransaction;
1112
import net.corda.core.transactions.TransactionBuilder;
@@ -95,15 +96,10 @@ public SignedTransaction call() throws FlowException {
9596
BlowWhistleState output = new BlowWhistleState(badCompany, anonymousMe, anonymousInvestigator);
9697
CommandData command = new BlowWhistleContract.Commands.BlowWhistleCmd();
9798

98-
// Obtain a reference to a notary we wish to use.
99-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
100-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
101-
*
102-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
103-
*/
104-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
105-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
10699

100+
// Obtain a reference to a notary we wish to use.
101+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
102+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
107103
TransactionBuilder txBuilder = new TransactionBuilder(notary)
108104
.addOutputState(output, BlowWhistleContract.ID)
109105
.addCommand(command, ImmutableList.of(anonymousMe.getOwningKey(), anonymousInvestigator.getOwningKey()));

Features/confidentialidentity-whistleblower/workflows/src/test/java/net/corda/samples/whistleblower/flows/FlowTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.concurrent.CordaFuture;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.core.transactions.SignedTransaction;
6-
import net.corda.testing.node.MockNetwork;
7-
import net.corda.testing.node.MockNetworkParameters;
8-
import net.corda.testing.node.StartedMockNode;
9-
import net.corda.testing.node.TestCordapp;
7+
import net.corda.testing.node.*;
108
import org.junit.After;
119
import org.junit.Before;
1210
import org.junit.Test;
@@ -17,7 +15,8 @@ public class FlowTests {
1715
private final MockNetwork network = new MockNetwork(new MockNetworkParameters()
1816
.withCordappsForAllNodes(ImmutableList.of(
1917
TestCordapp.findCordapp("net.corda.samples.whistleblower.contracts"),
20-
TestCordapp.findCordapp("net.corda.samples.whistleblower.flows"))));
18+
TestCordapp.findCordapp("net.corda.samples.whistleblower.flows")))
19+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB")))));
2120
private final StartedMockNode a = network.createNode();
2221
private final StartedMockNode b = network.createNode();
2322
private final StartedMockNode c = network.createNode();

Features/contractsdk-recordplayers/workflows/src/main/java/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlow.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import co.paralleluniverse.fibers.Suspendable;
44
import net.corda.core.contracts.UniqueIdentifier;
55
import net.corda.core.flows.*;
6+
import net.corda.core.identity.CordaX500Name;
67
import net.corda.core.identity.Party;
78
import net.corda.core.transactions.SignedTransaction;
89
import net.corda.core.transactions.TransactionBuilder;
@@ -52,7 +53,9 @@ public SignedTransaction call() throws FlowException {
5253
// ideally this is only run by the manufacturer
5354
this.manufacturer = getOurIdentity();
5455

55-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
56+
// Obtain a reference to a notary we wish to use.
57+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
58+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
5659

5760
Needle n = Needle.SPHERICAL;
5861

Features/contractsdk-recordplayers/workflows/src/main/java/net/corda/samples/contractsdk/flows/UpdateRecordPlayerFlow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public SignedTransaction call() throws FlowException {
8383
throw new IllegalArgumentException("Only the dealer that sold this record player can service it!");
8484
}
8585

86-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
86+
final Party notary = inputStateAndRef.getState().getNotary();
8787

8888
Command<RecordPlayerContract.Commands.Update> command = new Command<>(
8989
new RecordPlayerContract.Commands.Update(),

Features/contractsdk-recordplayers/workflows/src/test/java/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@
55
import net.corda.core.concurrent.CordaFuture;
66
import net.corda.core.contracts.TransactionState;
77
import net.corda.core.contracts.UniqueIdentifier;
8+
import net.corda.core.identity.CordaX500Name;
89
import net.corda.core.identity.Party;
910
import net.corda.core.node.NetworkParameters;
1011
import net.corda.core.transactions.SignedTransaction;
1112
import net.corda.samples.contractsdk.states.Needle;
1213
import net.corda.samples.contractsdk.states.RecordPlayerState;
13-
import net.corda.testing.node.MockNetwork;
14-
import net.corda.testing.node.MockNetworkParameters;
15-
import net.corda.testing.node.StartedMockNode;
16-
import net.corda.testing.node.TestCordapp;
14+
import net.corda.testing.node.*;
1715
import org.junit.After;
1816
import org.junit.Before;
1917
import org.junit.Rule;
@@ -51,6 +49,7 @@ public void setup() {
5149
network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(ImmutableList.of(
5250
TestCordapp.findCordapp("net.corda.samples.contractsdk.contracts"),
5351
TestCordapp.findCordapp("net.corda.samples.contractsdk.flows"))).withNetworkParameters(testNetworkParameters)
52+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
5453
);
5554

5655
manufacturerNode = network.createPartyNode(null);

0 commit comments

Comments
 (0)