-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintegrationTest.rho
62 lines (49 loc) · 2.51 KB
/
integrationTest.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/////////////////////////
// myRhobustContractTEST : test rhobustFactory102
new myRhobustContractTEST, ack, stdoutAck(`rho:io:stdoutAck`),
ackJoe, resJoe,
ackIrs, resIrs,
ackBoss, resBoss,
resProc_Joe,ackProc_Joe,
resProc_Irs,ackProc_Irs,
resProc_Boss,ackProc_Boss
in {
stdoutAck!("TEST : Creating sample rhobust contract. 3 agents (employer, employee, IRS)", *ack)
| // <- concurrent (log test start)
// TEST RhobustContracts
// The level of recursivity shown in this test is needed to simulate sequential actions of each agent
// In real life, agents interact INDEPENDENTLY and sometimes CONCURRENTLY.
// in Rholang, concurrency is handled gracefully. this is why simulating sequencial actions is harder ^^
new myRhobustContractTEST, myRhobustContract_Joe , myRhobustContract_Irs , myRhobustContract_Boss, ack,
stdout(`rho:io:stdout`), stdoutAck(`rho:io:stdoutAck`) in {
stdout!("TEST STEP 1 : Creating sample rhobust contract") |
@"RhobustFactory"!(*myRhobustContractTEST, 3, *ack) |
for(@uri2 <- ack) {
//stdout!(uri2) |
// uri2 is sent to all 3 agents.
// Agent A (Joe) stores uri2 in a safe place
// Agent B (IRS) stores uri2 in a safe place
// Agent C (boss) stores uri2 in a safe place
// Later on, agent A (Joe) logs in to sign the contract
// this results in a lookup in the tuplespace using uri
@"RhobustFactory"!(*myRhobustContract_Joe, uri2,"sign", "Joe","secretkey_employee", *ackJoe) |
for(resJoe <- ackJoe) {
stdout!(*resJoe) |
// Later on, agent B (irs) logs in to sign the contract
// this results in a lookup in the tuplespace using uri
@"RhobustFactory"!(*myRhobustContract_Irs, uri2,"sign", "irs","secretkey_irs", *ackIrs) |
for(resIrs <- ackIrs) {
stdout!(*resIrs) |
// Later on, agent C (boss) logs in to sign the contract
// this results in a lookup in the tuplespace using uri
@"RhobustFactory"!(*myRhobustContract_Boss, uri2,"sign", "boss","secretkey_employer", *ackBoss) |
for(resBoss <- ackBoss){
stdout!(*resBoss)
// identification done for boss
// + payment done (lots of thing happened)
}
}
}
}
}
}