-
Notifications
You must be signed in to change notification settings - Fork 1
Add IOTA Tangle assessor. #8
Add IOTA Tangle assessor. #8
Conversation
9deeb52
to
8fa5485
Compare
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.
Rebase.
Decouple IPFS. Basic assessor should simply validate the IOTA annotation from the local store points to valid content on the Tangle. Follow-on enhancement would be to provide a closure/interface to the assessor that would evaluate the content retrieved from the Tangle for correctness. The closure/interface implementation would live outside of the IOTA assessor. Do the basic assessor for this PR and we can work together on the enhancement as a separate issue/PR.
Implement factories and related support to ensure strongly-typed structures are unmarshaled.
Let's discuss if you have questions.
Signed-off-by: Jason Bonafide <[email protected]>
8fa5485
to
721a7a5
Compare
@michaelestrin Update the PR with the mentioned changes:
|
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.
cmd/examples/multistage/main.go
Outdated
@@ -40,9 +42,12 @@ import ( | |||
"github.com/project-alvarium/go-sdk/pkg/annotator/provenance" | |||
"github.com/project-alvarium/go-sdk/pkg/annotator/publish" | |||
publishMetadata "github.com/project-alvarium/go-sdk/pkg/annotator/publish/metadata" | |||
publisherMetadataFactory "github.com/project-alvarium/go-sdk/pkg/annotator/publish/metadata/factory" |
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.
Alias should be publishMetadataFactory
.
cmd/examples/multistage/main.go
Outdated
filterFactory.New( | ||
func(annotation *annotation.Instance) bool { | ||
t, ok := annotation.Metadata.(*publishMetadata.Instance) | ||
return ok && t.PublisherKind == iotaPublisherMetadata.Kind | ||
}, | ||
), |
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.
Replace with passthroughFilter
.
cmd/examples/multistage/main.go
Outdated
persistence, | ||
iotaAssessor.New( | ||
newClient(iotaURL), | ||
publisherMetadataFactory.New([]metadataFactory.Contract{iotaMetadataFactory.New()}), |
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.
Replace with publisherMetadataFactory.NewDefault()
. You'll likely extract this to a variable in a follow-on PR to reuse the resulting instance to assess IPFS publisher annotations.
internal/pkg/test/iota.go
Outdated
@@ -57,3 +71,32 @@ func FactoryRandomFixedSizeBundle(size int) bundle.Bundle { | |||
} | |||
return txs | |||
} | |||
|
|||
// FactoryAnnotationTransaction returns a Transaction comprised of a single annotation instance. | |||
func FactoryAnnotationTransaction(t *testing.T, unique string, metadata metadata.Contract) transaction.Transaction { |
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.
t parameter isn't used; remove it.
internal/pkg/test/iota.go
Outdated
return &annotation.Instance{ | ||
Unique: unique, | ||
Created: test.FactoryRandomString(), | ||
CurrentIdentityKind: test.FactoryRandomString(), | ||
CurrentIdentity: identityProvider.New(sha256.New()).Derive(test.FactoryRandomByteSlice()), | ||
PreviousIdentityKind: test.FactoryRandomString(), | ||
PreviousIdentity: nil, | ||
MetadataKind: publishMetadata.Kind, | ||
Metadata: metadata, | ||
} |
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.
Don't initialize the struct directly; use annotation.New()
instead. Using a factory function when one is available should always be preferred over direct assignment. The factory function's purpose is to provide a properly initialized receiver (something you're not guaranteed to get here when annotation.Instance evolves and this instance isn't updated).
), | ||
), | ||
}, | ||
client: stub.New([]transaction.Transactions{{}}, nil), |
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.
{{}}
-> {}
), | ||
), | ||
}, | ||
client: stub.New([]transaction.Transactions{{}}, nil), |
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.
{{}}
-> {}
), | ||
), | ||
}, | ||
client: stub.New([]transaction.Transactions{{}}, nil), |
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.
{{}}
-> {}
), | ||
), | ||
}, | ||
client: stub.New([]transaction.Transactions{{}}, err), |
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.
{{}}
-> {}
|
||
"github.com/project-alvarium/go-sdk/pkg/test" | ||
|
||
"github.com/magiconair/properties/assert" |
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.
Wrong library. Use github.com/stretchr/testify/assert instead.
Note also your commit comment isn't auto-closing the corresponding issue. Use a supported keyword in place of "Addresses" (see https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) |
Closed without merge. |
Addresses: #4
Signed-off-by: Jason Bonafide [email protected]