-
Notifications
You must be signed in to change notification settings - Fork 110
swap: replaced Owner for Issuer #1720
Changes from all commits
82aa9e3
9c7a0ee
4694a7c
5331f06
4d43225
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,7 +105,7 @@ func (s *Swap) run(p *p2p.Peer, rw p2p.MsgReadWriter) error { | |
protoPeer := protocols.NewPeer(p, rw, Spec) | ||
|
||
handshake, err := protoPeer.Handshake(context.Background(), &HandshakeMsg{ | ||
ContractAddress: s.owner.Contract, | ||
ContractAddress: s.issuer.Contract, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is exactly what I meant this morning in the call. This is the handshake. At this point, two nodes are just exchanging contract addresses. We don't even know what balances there are (they might be 0 on both sides at this point!). Thus, I see it as incorrect to change this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i agree. if we don't want to use in any case, the golang context is different from the SC context, so it wouldn't bother me if we were to use additional terms on either side that the other side doesn't. i'd just insist on using the same terms when referring to the same entities, specially in variables or fields. |
||
}, s.verifyHandshake) | ||
if err != nil { | ||
return err | ||
|
@@ -116,7 +116,7 @@ func (s *Swap) run(p *p2p.Peer, rw p2p.MsgReadWriter) error { | |
return ErrInvalidHandshakeMsg | ||
} | ||
|
||
beneficiary, err := s.getContractOwner(context.Background(), response.ContractAddress) | ||
beneficiary, err := s.getIssuerAtContract(context.Background(), response.ContractAddress) | ||
if err != nil { | ||
return err | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,7 @@ func TestHandshake(t *testing.T) { | |
var err error | ||
|
||
// setup test swap object | ||
swap, clean := newTestSwap(t, ownerKey) | ||
swap, clean := newTestSwap(t, issuerKey) | ||
defer clean() | ||
|
||
ctx := context.Background() | ||
|
@@ -47,7 +47,7 @@ func TestHandshake(t *testing.T) { | |
t.Fatal(err) | ||
} | ||
// setup the protocolTester, which will allow protocol testing by sending messages | ||
protocolTester := p2ptest.NewProtocolTester(swap.owner.privateKey, 2, swap.run) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, as commented above (i will refrain from repeating it from here onwards) |
||
protocolTester := p2ptest.NewProtocolTester(swap.issuer.privateKey, 2, swap.run) | ||
|
||
// shortcut to creditor node | ||
debitor := protocolTester.Nodes[0] | ||
|
@@ -60,7 +60,7 @@ func TestHandshake(t *testing.T) { | |
cheque := newTestCheque() | ||
|
||
// sign the cheque | ||
cheque.Signature, err = cheque.Sign(swap.owner.privateKey) | ||
cheque.Signature, err = cheque.Sign(swap.issuer.privateKey) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
@@ -83,14 +83,14 @@ func TestHandshake(t *testing.T) { | |
{ | ||
Code: 0, | ||
Msg: &HandshakeMsg{ | ||
ContractAddress: swap.owner.Contract, | ||
ContractAddress: swap.issuer.Contract, | ||
}, | ||
Peer: creditor.ID(), | ||
}, | ||
{ | ||
Code: 0, | ||
Msg: &HandshakeMsg{ | ||
ContractAddress: swap.owner.Contract, | ||
ContractAddress: swap.issuer.Contract, | ||
}, | ||
Peer: debitor.ID(), | ||
}, | ||
|
@@ -112,7 +112,7 @@ func TestHandshake(t *testing.T) { | |
func TestEmitCheque(t *testing.T) { | ||
log.Debug("set up test swaps") | ||
creditorSwap, clean1 := newTestSwap(t, beneficiaryKey) | ||
debitorSwap, clean2 := newTestSwap(t, ownerKey) | ||
debitorSwap, clean2 := newTestSwap(t, issuerKey) | ||
defer clean1() | ||
defer clean2() | ||
|
||
|
@@ -133,7 +133,7 @@ func TestEmitCheque(t *testing.T) { | |
// create the debitor peer | ||
dPtpPeer := p2p.NewPeer(enode.ID{}, "debitor", []p2p.Cap{}) | ||
dProtoPeer := protocols.NewPeer(dPtpPeer, nil, Spec) | ||
debitor := NewPeer(dProtoPeer, creditorSwap, debitorSwap.owner.address, debitorSwap.owner.Contract) | ||
debitor := NewPeer(dProtoPeer, creditorSwap, debitorSwap.issuer.address, debitorSwap.issuer.Contract) | ||
|
||
// set balance artificially | ||
creditorSwap.balances[debitor.ID()] = 42 | ||
|
@@ -146,13 +146,13 @@ func TestEmitCheque(t *testing.T) { | |
log.Debug("create a cheque") | ||
cheque := &Cheque{ | ||
ChequeParams: ChequeParams{ | ||
Contract: debitorSwap.owner.Contract, | ||
Beneficiary: creditorSwap.owner.address, | ||
Contract: debitorSwap.issuer.Contract, | ||
Beneficiary: creditorSwap.issuer.address, | ||
CumulativePayout: 42, | ||
}, | ||
Honey: 42, | ||
} | ||
cheque.Signature, err = cheque.Sign(debitorSwap.owner.privateKey) | ||
cheque.Signature, err = cheque.Sign(debitorSwap.issuer.privateKey) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
@@ -199,7 +199,7 @@ func TestEmitCheque(t *testing.T) { | |
// It is the debitor who triggers cheques | ||
func TestTriggerPaymentThreshold(t *testing.T) { | ||
log.Debug("create test swap") | ||
debitorSwap, clean := newTestSwap(t, ownerKey) | ||
debitorSwap, clean := newTestSwap(t, issuerKey) | ||
defer clean() | ||
|
||
// setup the wait for mined transaction function for testing | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if i understand this correctly, the mentioned
counterparty
here would be the peerp
, right?i find it confusing to call this
beneficiary
, as it could be interpreted as the address this peer writes cheques to or the address this peer wants its cheques written to just as well.also: remove
.
from this commentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree about
beneficiary
being confusing. I would change it top.counterparty