New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MYST-18 define client promise #32
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d4695ad
initial promise definition
interro 5c9bca3
remove unneeded fields
interro d74814f
promise dto
interro cd49cfb
simple promise test
interro 6c8872d
rename file
interro 65a29f7
promise body & signature
interro 3c07d9f
Merge remote-tracking branch 'origin/master' into feature/MYST-18-cli…
interro 27b0998
single name for currency
interro f45453b
tokens expressed as uint
interro 4d56116
test for amount
interro a78630d
test for signed promise
interro e23eb11
remove promise example json
interro 71e5cab
token value in uint64
interro File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package dto | ||
|
||
import "github.com/mysterium/node/service_discovery/dto" | ||
|
||
type PromiseBody struct { | ||
SerialNumber int | ||
IssuerId string | ||
BenefiterId string | ||
Amount dto.Money | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package dto | ||
|
||
type Signature string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dto | ||
|
||
type SignedPromise struct { | ||
Promise PromiseBody | ||
IssuerSignature Signature | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package client_promise | ||
|
||
import ( | ||
dto "github.com/mysterium/node/client_promise/dto" | ||
discovery_dto "github.com/mysterium/node/service_discovery/dto" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func Test_PromiseBody(t *testing.T) { | ||
|
||
amount := discovery_dto.Money{ | ||
Amount: uint64(5), | ||
Currency: "Token", | ||
} | ||
|
||
promise := dto.PromiseBody{ | ||
SerialNumber: 1, | ||
IssuerId: "issuer1", | ||
BenefiterId: "benefiter1", | ||
Amount: amount, | ||
} | ||
|
||
assert.Equal(t, promise.SerialNumber, 1) | ||
assert.Equal(t, promise.IssuerId, "issuer1") | ||
assert.Equal(t, promise.BenefiterId, "benefiter1") | ||
assert.Equal(t, promise.Amount.Amount, uint64(5)) | ||
assert.Equal(t, promise.Amount.Currency, "Token") | ||
} | ||
|
||
func Test_SignedPromise(t *testing.T) { | ||
|
||
promise := dto.PromiseBody{} | ||
|
||
signedPromise := dto.SignedPromise{ | ||
Promise: promise, | ||
IssuerSignature: "signature", | ||
} | ||
|
||
assert.Equal(t, signedPromise.Promise, promise) | ||
assert.Equal(t, signedPromise.IssuerSignature, dto.Signature("signature")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package dto | ||
|
||
type Money struct { | ||
Amount uint64 | ||
Currency string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Some tests probably broke, check by running
bin/test