File tree Expand file tree Collapse file tree 12 files changed +140
-47
lines changed
Features/schedulablestate-heartbeat
main/java/net/corda/samples/heartbeat
test/java/net/corda/samples/heartbeat/contracts
main/java/net/corda/samples/heartbeat/flows
test/java/net/corda/samples/heartbeat/flows Expand file tree Collapse file tree 12 files changed +140
-47
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ buildscript {
2828}
2929
3030allprojects {
31-
3231 repositories {
3332 mavenLocal()
3433 jcenter()
@@ -37,4 +36,32 @@ allprojects {
3736 maven { url ' https://software.r3.com/artifactory/corda' }
3837 maven { url ' https://repo.gradle.org/gradle/libs-releases' }
3938 }
40- }
39+ }
40+
41+ task deployNodes (type : net.corda.plugins.Cordform , dependsOn : [' jar' ]) {
42+ nodeDefaults {
43+ cordapp project(" contracts" )
44+ cordapp project(" workflows" )
45+ }
46+ node {
47+ name " O=Notary,L=London,C=GB"
48+ notary = [validating : true ]
49+ p2pPort 10002
50+ rpcSettings {
51+ address(" localhost:10003" )
52+ adminAddress(" localhost:10043" )
53+ }
54+ cordapps = []
55+ runSchemaMigration = true
56+ }
57+ node {
58+ name " O=PartyA,L=London,C=GB"
59+ p2pPort 10004
60+ rpcSettings {
61+ address(" localhost:10006" )
62+ adminAddress(" localhost:10046" )
63+ }
64+ cordapps = []
65+ rpcUsers = [[ user : " user1" , " password" : " test" , " permissions" : [" ALL" ]]]
66+ }
67+ }
Original file line number Diff line number Diff line change @@ -7,13 +7,28 @@ cordapp {
77 targetPlatformVersion corda_platform_version. toInteger()
88 minimumPlatformVersion corda_platform_version. toInteger()
99 contract {
10- name " Heartbeat"
10+ name " SchedulableState Heartbeat"
1111 vendor " Corda Open Source"
1212 licence " Apache License, Version 2.0"
1313 versionId 1
1414 }
1515}
1616
17+ sourceSets {
18+ main {
19+ java {
20+ srcDir ' src/main/java'
21+ java. outputDir = file(' bin/main' )
22+ }
23+ }
24+ test {
25+ java {
26+ srcDir ' src/test/java'
27+ java. outputDir = file(' bin/test' )
28+ }
29+ }
30+ }
31+
1732dependencies {
1833 testCompile " junit:junit:$junit_version "
1934
3550
3651tasks. withType(JavaCompile ) {
3752 options. compilerArgs << " -parameters" // Required for shell commands.
38- }
53+ }
Original file line number Diff line number Diff line change 1- package com .heartbeat .contracts ;
1+ package net . corda . samples .heartbeat .contracts ;
22
33import net .corda .core .contracts .CommandData ;
44import net .corda .core .contracts .Contract ;
99 * A blank contract and command, solely used for building a valid Heartbeat state transaction.
1010 */
1111public class HeartContract implements Contract {
12- public final static String contractID = "com .heartbeat.contracts.HeartContract" ;
12+ public final static String contractID = "net.corda.samples .heartbeat.contracts.HeartContract" ;
1313
1414 @ Override
1515 public void verify (@ NotNull LedgerTransaction tx ) throws IllegalArgumentException {
Original file line number Diff line number Diff line change 1- package com . heartbeat .contracts ;
1+ package net . corda . samples . heartbeat .states ;
22
33import net .corda .core .contracts .BelongsToContract ;
44import net .corda .core .contracts .SchedulableState ;
88import net .corda .core .identity .AbstractParty ;
99import net .corda .core .identity .Party ;
1010import net .corda .core .serialization .ConstructorForDeserialization ;
11+ import net .corda .samples .heartbeat .contracts .HeartContract ;
1112import org .jetbrains .annotations .NotNull ;
1213import org .jetbrains .annotations .Nullable ;
1314
Original file line number Diff line number Diff line change 1+ package net .corda .samples .heartbeat .contracts ;
2+
3+ import net .corda .core .contracts .Contract ;
4+ import net .corda .core .identity .CordaX500Name ;
5+ import net .corda .samples .heartbeat .states .HeartState ;
6+ import net .corda .testing .core .TestIdentity ;
7+ import net .corda .testing .node .MockServices ;
8+ import org .junit .Test ;
9+
10+ import java .util .Arrays ;
11+
12+ import static net .corda .testing .node .NodeTestUtils .transaction ;
13+
14+ public class HeartContractTests {
15+
16+ private final TestIdentity a = new TestIdentity (new CordaX500Name ("Alice" , "" , "GB" ));
17+ private final TestIdentity b = new TestIdentity (new CordaX500Name ("Bob" , "" , "GB" ));
18+
19+ private MockServices ledgerServices = new MockServices (
20+ Arrays .asList ("net.corda.samples.heartbeat.contracts" )
21+ );
22+
23+ HeartState st = new HeartState (a .getParty ());
24+
25+ @ Test
26+ public void contractImplementsContract () {
27+ assert (new HeartContract () instanceof Contract );
28+ }
29+
30+ @ Test
31+ public void contractRequiresSpecificCommand () {
32+ transaction (ledgerServices , tx -> {
33+ // Has correct command type, will verify.
34+ tx .output (HeartContract .contractID , st );
35+ tx .command (Arrays .asList (a .getPublicKey ()), new HeartContract .Commands .Beat ());
36+ tx .verifies ();
37+ return null ;
38+ });
39+ }
40+
41+ }
Original file line number Diff line number Diff line change 1+ package net .corda .samples .heartbeat .contracts ;
2+
3+ import net .corda .core .contracts .ContractState ;
4+ import net .corda .core .contracts .SchedulableState ;
5+ import net .corda .core .identity .CordaX500Name ;
6+ import net .corda .samples .heartbeat .states .HeartState ;
7+ import net .corda .testing .core .TestIdentity ;
8+ import org .junit .jupiter .api .Test ;
9+
10+ import static org .jgroups .util .Util .assertFalse ;
11+ import static org .jgroups .util .Util .assertTrue ;
12+
13+ public class HeartStateTests {
14+
15+ private final TestIdentity a = new TestIdentity (new CordaX500Name ("Alice" , "" , "GB" ));
16+ private final TestIdentity b = new TestIdentity (new CordaX500Name ("Bob" , "" , "GB" ));
17+
18+ @ Test
19+ public void constructorTest () {
20+ HeartState st = new HeartState (a .getParty ());
21+
22+ assertTrue (st .getParticipants ().contains (a .getParty ()));
23+ assertFalse (st .getParticipants ().contains (b .getParty ()));
24+ }
25+
26+ @ Test
27+ public void stateImplementsContractStateTest () {
28+ HeartState st = new HeartState (a .getParty ());
29+ assertTrue (st instanceof ContractState );
30+ assertTrue (st instanceof SchedulableState );
31+ }
32+ }
33+
34+
35+
Original file line number Diff line number Diff line change 1- name =<AppName>
2- group =<pkg>
1+ name =SchedulableState Heartbeat
2+ group =com.heartbeat
33version =0.2
Original file line number Diff line number Diff line change @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
22distributionPath =wrapper/dists
33zipStoreBase =GRADLE_USER_HOME
44zipStorePath =wrapper/dists
5- distributionUrl =https\://services.gradle.org/distributions/gradle-5.4.1 -all.zip
5+ distributionUrl =https\://services.gradle.org/distributions/gradle-5.6.4 -all.zip
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ cordapp {
77 targetPlatformVersion corda_platform_version. toInteger()
88 minimumPlatformVersion corda_platform_version. toInteger()
99 workflow {
10- name " Heartbeat"
10+ name " SchedulableState Heartbeat"
1111 vendor " Corda Open Source"
1212 licence " Apache License, Version 2.0"
1313 versionId 1
@@ -39,29 +39,4 @@ tasks.withType(JavaCompile) {
3939 options. compilerArgs << " -parameters" // Required for shell commands.
4040}
4141
42- task deployNodes (type : net.corda.plugins.Cordform , dependsOn : [' jar' ]) {
43- nodeDefaults {
44- cordapp project(" :contracts" )
45- }
46- node {
47- name " O=Notary,L=London,C=GB"
48- notary = [validating : true ]
49- p2pPort 10002
50- rpcSettings {
51- address(" localhost:10003" )
52- adminAddress(" localhost:10043" )
53- }
54- cordapps = []
55- runSchemaMigration = true
56- }
57- node {
58- name " O=PartyA,L=London,C=GB"
59- p2pPort 10004
60- rpcSettings {
61- address(" localhost:10006" )
62- adminAddress(" localhost:10046" )
63- }
64- cordapps = []
65- rpcUsers = [[ user : " user1" , " password" : " test" , " permissions" : [" ALL" ]]]
66- }
67- }
42+
Original file line number Diff line number Diff line change 1- package com .heartbeat .flows ;
1+ package net . corda . samples .heartbeat .flows ;
22
33import co .paralleluniverse .fibers .Suspendable ;
4- import com .heartbeat .contracts .HeartContract ;
5- import com . heartbeat .contracts .HeartState ;
4+ import net . corda . samples .heartbeat .contracts .HeartContract ;
5+ import net . corda . samples . heartbeat .states .HeartState ;
66import net .corda .core .contracts .*;
77import net .corda .core .flows .*;
88import net .corda .core .identity .Party ;
You can’t perform that action at this time.
0 commit comments