Skip to content

Commit

Permalink
Merging Develop -> Master (#669)
Browse files Browse the repository at this point in the history
* fix builds

* rename COC for github (#382)

* Hardcode External IP (#386)

* Hardcode External IP

* Hardcode External IP

* Add Connect timeout to p2p conns (#387)

* Add Connect timeout to p2p conns

* add exported comment

* Added timeout for eth read operations (#388)

* Added timeout for read operations

* fix unit test

* manual group import

* Flatten Core document and P2P packages (#385)

* Fix Gopkg github repo URLs (#393)

* Fix github links

* try http

* Upgrading to Go 1.11.x (#391)

* Identity Config cleanup (#396)

* identity cleanup

* 20byte for secp

* some test

* clean up anchors (#398)

1. Better comments
2. renamed `NewAnchorID` -> `ToAnchorID` since this is conversion but not a creation
3. renamed `NewDocRoot` -> `ToDocumentRoot` since this is conversion
4. renamed `NewRandomDocRoot` -> `RandomDocumentRoot` 
5. Unexported `anchorCommittedWatcher`, `anchorConfirmationTask`

* refactor identity (#399)

1. Unexported constants
2. Unexported Worker Task
3. unexported `ethereumIdentity`

* Refactor geth (#397)

1. Minor changes to how we increment nonce and added more tests for the nonce increment
2. Mutex for accounts for read and write
3. Unported `GethClient`
4. Removed definitions that are not used in the interface

* fix the race condition with config (#401)

Fixes #389 
Fixes #362 

Turns out both the issues were due to `config.Config` variable being accessed at the same time. #389, it is accessed in `notification.Send` and in #362 it is accessed to set Config to nil in `config/test_bootstrapper.go`.

All the tests share a global namespace and since they are run in parallel and each time the `config/test_boostrapper` is run in each test, which is updating `config.Config`, the race condition happens. Added a functions to set and get config with mutex.

* Hex convert webhook fields (#409)

* Hex convert webhook fields

* Hex convert webhook fields

* Test

* Updated Precise proof with hex value (#414)

* Add api logs (#413)

* Add api logs

* Review comments

* Adding notification sample to config example (#416)

* NFT: added events/workers, latest contract version, using centrifuge/go-ethereum (#400)

* Fix problem with creating ids

* Worker for watching NFT minting events

* Worker for watching NFT minting events

* added correct encoding for worker

* formatting

* updated to latest paymentObligation contract version

* correct collaborators passing

* latest centrifuge contracts & using centrifuge/go-ethereum

* fixed dependencies except contracts

* added latest contracts

* reset integration test config

* formatting

* fixed unit tests for nft minting

* reduced scope of public variables

* formatting

* reduced public functions in nft package

* add additional nil checks for data in the payload (#424)

Fixes #419 

Functional tests will be done once this is merged to develop

* First Step config (#422)

* First Phase config

* cleanup

*  First batch of removing global config access (#441)

* First Phase config

* cleanup

* global removal

* nft: added format checks for collaborator proofField (#442)

* added collaborators field check

* improved regex performance

* NFT: using passed registryAddress for dynamic contract binding (#443)

* added generic registry address support

* remove global dependencies for p2p layer (#446)

* remove global dependencies for p2p layer

* add p2p boostrap

* remove test checks

* use ctx from args

* fix tests

* check for startup errors

* better tests

* remove debug point

* fix tests

* Fix/p2p test (#449)

* fix the deadlock

* dont propagte shutdown error

* propagate the ctx

* NFT: added tests for minting confirmation task (#445)

added tests for checking the correct parsing of the arguments

* NFT: removed type parameter from endpoint (#448)

* removed type from nft endpoint

* find service based on documentID

* added tests for findService

* fixed findService test

* fixed unit tests for type field

* deactivated the test case

* NFT: usage of depositAddress parameter (#456)

* removed usage of identity contract address for mint method

* remove global registry service (#457)

Removes global service registry

* Refactor stateful methods into identity.Service interface (#410)

* Refactor stateful methods into ethereum.Client interface

* State save tests fail

* Fixing processor tests

* More tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Fix tests

* Missing build tag

* identity.go coverage (#463)

* identity.go coverage

* correct test

* add status mapping in PO (#462)

Fixes #455

* remove global anchor repo (#464)

Fixes #459

* add missing registry (#466)

Fixes the functional tests

* Fix unit tests (#467)

* Remove global configuration usage (#460)

* First Phase config

* cleanup

* global removal

* added contextHeader

* avoid cyclic deps

* hell

* hell 2

* pass duration param queue + fix unit tests

* remove global config var

* Remove global + queue timeout param

* fix tests + config interface

* comments

* Fix unit tests

* package Configs

* fix missing po config (#470)

* Kovan/fixes (#471)

Changes:
- Create default config for Kovan
- Minor changes to createconfig to support txpoolaccess option
- logging fixes
- Use go-ethereum with kovan fixes

Fixes https://github.com/centrifuge/roadmap/issues/61

* Remove usage of identity.IDService (#473)

* Remove usage of identity.IDService

* Fix test

* Fix test

* Pprof/endpoint (#476)

* add pprof port to config

* add pprof end points

* review changes

* Remove PaymentObligation global (var po *ethereumPaymentObligation) (#478)

* Remove PaymentObligation global

* Fmt

* Include prefix precise proof (#477)

* include prefix precise proof

* comment out test

* Queue implements Server and removing the queue.Queue global (#469)

* Queue implements Server and removing the queue.Queue global

* Looks good

* Fix tests

* Fix problem with init

* More queue init fixes

* More queue init fixes

* Fix tests

* Fix tests

* Fix tests

* Lock for qs.stop

* Fix race conditions

* Fix problems and review comments

* Fix problems and review comments

* Fix problems and review comments

* Fix problems and review comments

* Lock

* Lock

* Lock

* model test

* Add linting checks (#479)

Changes:
- Added gometalinter
- following checks are enabled: goimport, vet, staticcheck, nakedret

Following changes are suggested by these linters. We still need to add few more linters which we can do on a regular basis.

Fixes #475

* Fixing merging issue with an earlier pr (#480)

* Fixing merging issue with earlier pr

* Fix

* Fix cmds that were broken (#494)

* Fix cmds that were broken

* Imports

* Remove storage.levelDBInstance global (#524)

* Remove storage.levelDBInstance global

* fix tests

* fix tests

* imports

* Rename `go-centrifuge` to `centrifuge` (#525)

Fixes #493

* use http jsonrpc (#522)

* NFT: unlimited amount of proofs and no collaborator extra field (#526)

* added new gobinding and refactored for handler tests

* refactored nft servic tests

* refactored integration tests

* formatting

* Integration testing framework(Testworld) first iteration (#512)

* Fixing merging issue with earlier pr

* V1

* Peer init works

* Remove storage.levelDBInstance global

* Testworld mods

* fix tests

* fix tests

* imports

* First working hosts

* First successful Testworld tests

* Added Robert and the park hosts in a nicer way

* Fix linting issues

* Fix gitignore

* Review comments

* Fix create an already updated version for first time (#527)

* updated paymentObligation addresses for rinkeby and kovan (#530)

* use internal error for context (#531)

* NFT: fixed incorrect tokenID size (#532)

* NFT: fixed incorrect tokenID size

* better comments

* Testworld iteration 2 - cleanup and more golang based env setup (#529)

* Added Testworld readme

* Load config from file

* Testworld cleanup

* Add missing build tag

* Fix lint issues

* Adjust the way smart contract addresses are loaded for other networks

* Added kovan faq

* Minor update to the readme

* Review comments

* Clean gitignore

* Fixing unnecessary for loops that I have written around selects (#533)

* Fix unnecessary for loops that I have written around selects

* Remove resolved TODO

* Add update collaborator test (#535)

* Add update collaborator test

* Add update collaborator test

* removed defaultRegistry address from service (#536)

* update kovan boot nodes (#538)

* remove envs from yml (#540)

* Generic db implementation (#534)

Fixes #503 

Note:
This is just the implementation. Further PRs should handle integration to Invoice and PO

* integration test: added node time out test & improved test framework (#539)

* added cancel func to host

* added utils func and basic setup for timeout test

* formatting

* finished nodeTime test

* improved existing testcases

* removed uncommented code

* added testSuite to hostManager

* restart alice after shutdown

* added own node for timeout

* added timeout after re-start

* added restart method

* increased timeout

* Update README.md (#545)

* Added node defaults to default config (#541)

* Testworld: detect when host is live instead of waiting arbitrarily (#546)

* Minor adjustments

* Detect when host is live instead of waiting arbitrarily

* move to original geth (#547)

* Fix p2p timeouts and make Testworld parallel and faster (#548)

* Fix timeouts and make Testworld faster

* Fix test

* Make tests parallel

* Remove unnecessary iteration in test scripts

* Test script update

* Make tests parrallel and work

* Make tests parrallel and work

* Fix for migrate bash script (#549)

* Errors/internal (#543)

Fixes #537 

Note: This only adds internal errors. We need to add client and peerError later

* Tenant config model (#544)

* Node and Tenant config models

* Node and Tenant config models

* Test update

* Fix mistake

* Review comments

* use config interface (#552)

We seem to using config structure when we have an interface. This PR should take care of using interfaces everywhere

* Spaces

* added integration tests for NFT (#555)

* added NFT successful test case to integration tests

* added error tests for NFT

*  Migrate documents package to use new errors (#553)

* Migrate documents package to use new errors

* typeerror -> typederror

* Fix failing tests

* Fix fmt errors

* Fix error name

* Fix error name

*  Migrate invoice service to new repo (#554)

* Migrate documents package to use new errors

* typeerror -> typederror

* Fix failing tests

* Migrate invoice service to new repo

* Fix fmt errors

* Migrate new repository to new errors

* Fix test

* Fix test

* Fix lint issue

* Fix error name

* Fix error name

* added testworld tests for proofs (#556)

* added testworld tests for proofs

* added proof check for bob

*  Migrate po service to new repo (#557)

* Migrate documents package to use new errors

* typeerror -> typederror

* Fix failing tests

* Migrate invoice service to new repo

* Fix fmt errors

* Migrate new repository to new errors

* Fix test

* Fix test

* Fix lint issue

* Fix error name

* Fix error name

* Migrate PO service to new repository

* Remove legacy repo (#558)

* Migrate documents package to use new errors

* typeerror -> typederror

* Fix failing tests

* Migrate invoice service to new repo

* Fix fmt errors

* Migrate new repository to new errors

* Fix test

* Fix test

* Fix lint issue

* Fix error name

* Fix error name

* Migrate PO service to new repository

* Remove legacy repo

* added support for PO tests to testworld (#566)

* added testworld tests for proofs

* simple tests refactored

* added PO basic tests

* updated all PO tests

* included tests for NFT

* correct travis config

* fixed nft for PO

* fixed linting and pararell collaborator timeout

* deactivate unstable testcase

* Fixing some possible bugs because of colliding variable names with packages (#568)

*  Remove fmt.Errorf in favour of errors.New (#559)

* Migrate documents package to use new errors

* typeerror -> typederror

* Fix failing tests

* Migrate invoice service to new repo

* Fix fmt errors

* Migrate new repository to new errors

* Fix test

* Fix test

* Fix lint issue

* Fix error name

* Fix error name

* Migrate PO service to new repository

* Remove legacy repo

* Remove fmt.Errorf in favour of errors.New

* Fix problems

* Fix lint

* Missed stuff

* Make tests into a table and parallel (#569)

* Make tests into a table and parallel

* Make tests into a table and parallel

* Make tests into a table and parallel

* Config repository  (#560)

* Config Repositories

* fmt

* fix test

* move config around

* fmt

* fmt

* fmt

* try higher timeout

* Introduce Teddy and Dolores

* Revert "Introduce Teddy and Dolores"

This reverts commit 1a5dbf7.

* Skip timeout tests on CI to avoid resource problems (#570)

* go version 1.11.3 bug, lock to 1.11.2 (#571)

* move to 1.11.4 (#573)

* Consolidate DB Repository (#574)

* encapsulated DB interface

* lint

* added typed errors

* fix integration test

* fix integration test

* remove ID from storage.Repository

* ISSUE and PR templates proposal (#551)

* ISSUE and PR templates proposal

* Updates

* Update ISSUE_TEMPLATE.md

* Update PULL_REQUEST_TEMPLATE.md

* Update PULL_REQUEST_TEMPLATE.md

* Update ISSUE_TEMPLATE.md

* Cleanup testworld generated files (#578)

* Cleanup testworld generated files

* Force delete

* HTTP header for tenantID (#575)

Fixes #488 

1. Add interceptor that require header 'authorization' which holds tenantID
2. Add basic version if HTTPError and http Error response interceptor since we ned it for point 1

* added a generic document service (#579)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* document service: added CreateProof to model (#581)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* generated genericdoc package

* moved service_test

* added CreateProof to model

* changed to correct create proofs

* formatting

* correct flags

* moved service_test.go

* document service: createProof and CreateProofForVersion (#584)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* generated genericdoc package

* moved service_test

* added CreateProof to model

* changed to correct create proofs

* formatting

* correct flags

* added proof methods

* moved service_test.go

* added tests for createProof in service

* fixed broken createProofVersion test case

* formatting

* Transactions (#582)

* initial tx repo

* lint fixes

* document service: added RequestDocumentSignature and ReceiveAnchoredDocument (#586)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* generated genericdoc package

* moved service_test

* added CreateProof to model

* changed to correct create proofs

* formatting

* correct flags

* added proof methods

* moved service_test.go

* added tests for createProof in service

* implemented remaining methods for document service

* fixed broken createProofVersion test case

* formatting

* added tests for requestSignature

* formatting

* [Config DB] API Admin Endpoints (#583)

* Added proto models + service

* handler + service

* model tests

* add tests

* delete return

* missing tag

* proto

* [MultiTenancy] P2P refactorings No. 1 (#594)

* [MultiTenancy] P2P refactorings No. 1

* Fix problems

* Minor cleanups

* Debugged integration test

* Fix bug

* Fully debuggable integration tests (#595)

* [MultiTenancy] P2P refactorings No. 1

* Fix problems

* Minor cleanups

* Debugged integration test

* Fully debuggable integration tests

* Fix bug

* Minor

* Transaction Status Check API (#596)

Fixes #496 

- Add Transaction Status check endpoint

* Minor refactors (#600)

* remove signature package

* keytools => crypto

* remove signature package

* refactor bootstrappers

* rename contextheader

*  Convert ContextHeader to Context and make a util (#601)

* Fix error

* Convert ContextHeader to Context and make a util

* fix problem

* Fix lint issue

* Remove P2P GRPC (#597)

* Buggy iteration

* Remove GRPC POC

* Remove GRPC POC

* Fix lint

* Fix protobuf generated code

* Fixed client test

* Messenger tests

* Messenger tests

* correct testworld

* remove useless code

* Rename

* [MultiTenancy] Enable config database and api (#602)

* Enable config database and api

* Enable config database and api

* Minor

* Fix createConfig issue

* Add Testworld test for config API

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Lint fix

* Generate swagger

* Remove race detection from TestWorld to improve perf

* Fix unit tests

* REST fix /config/tenant => /config/tenants (#605)

* REST fix /config/tenant => /config/tenants

* REST fix /config/tenant => /config/tenants

* Async APIs (#598)

Fixes #497 #498 #499 

I started using commom.Address for tenant id since that is a requirement for transactions.
Note: This will break the functional tests.

* increment sleep to 1 sec

* [MultiTenancy] Use db stored config at runtime (#603)

* Enable config database and api

* Enable config database and api

* Minor

* Fix createConfig issue

* Add Testworld test for config API

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Lint fix

* Generate swagger

* Remove race detection from TestWorld to improve perf

* Use db stored config at runtime

* Lint and swagger

* Fix unit tests

* Fix tests

* Fix unit tests

* Remove -race from testworld

* Fix conflicts

* Try testworld without -race

* merging

* Merging still

* Fix confgi

* Fix test

* use json marshaller (#608)

* [MultiTenancy] Refactor identity package to remove cycles when using data structures from the interface (#606)

* Enable config database and api

* Enable config database and api

* Minor

* Fix createConfig issue

* Add Testworld test for config API

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Fix bug with GET /config/tenant/list (end point url ambigous)

* Lint fix

* Generate swagger

* Remove race detection from TestWorld to improve perf

* Use db stored config at runtime

* Lint and swagger

* Fix unit tests

* Fix tests

* Fix unit tests

* Remove -race from testworld

* Refactor identity and context

* Make identity work with db stored config

* Fix conflicts

* Fix test and lint

* Try testworld without -race

* merging

* Merging still

* Fix confgi

* Fix test

* Fix tests

* Multi tenancy service parts complete without api handlers and p2p handlers (#609)

* Multi tenancy complete without api handlers and p2p handlers

* Fixed unit tests

* Fix unit tests

* Fix unit tests

* Anchor uses tenant config (#618)

* Anchor uses tenant config

* Fix unit test

* genericDocumentService: added interface and bootstrappers (#610)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* generated genericdoc package

* moved service_test

* added CreateProof to model

* changed to correct create proofs

* formatting

* correct flags

* added proof methods

* moved service_test.go

* added tests for createProof in service

* implemented remaining methods for document service

* fixed broken createProofVersion test case

* formatting

* added tests for requestSignature

* formatting

* implemented own interface for generic document

* added bootstrapper to generic document service

* added bootstrapper for generic service

* fixed linting

* added bootstrapper for tests

* removed derive from cd

* removed cyclic dep

* formatting

* fixed api/server

* formatting

* formatting

* fixed api server

* correct testworld flags

* formatting

* Removing no longer used scripts (#621)

* using generic document service inside invoice service (#620)

* added testworld tests for proofs

* doc service with get and get version

* added test for getVersion

* added more tests for service get methods

* improved search and tests

* improved tests

* generated genericdoc package

* moved service_test

* added CreateProof to model

* changed to correct create proofs

* formatting

* correct flags

* added proof methods

* moved service_test.go

* added tests for createProof in service

* implemented remaining methods for document service

* fixed broken createProofVersion test case

* formatting

* added tests for requestSignature

* formatting

* implemented own interface for generic document

* added bootstrapper to generic document service

* added bootstrapper for generic service

* fixed linting

* added bootstrapper for tests

* removed derive from cd

* replaced getVersion for invoice with generic one

* removed cyclic dep

* formatting

* fixed api/server

* formatting

* fixed GetLatestVersion invoice

* formatting

* fixed api server

* correct testworld flags

* added generic exists to invoice

* added generic proof generation to invoice

* added generic requestDocumentSignature to invoice

* formatting

* formatting

* removed old tests

* using a embedded interface

* Identity package uses tenantConfig (#619)

* Identity package uses tenantConfig

* Fix testworld issue

* Fix problem

* NFT: using generic document service (#622)

* added testworld tests for proofs

* implemented NFT with generic service

* correct flags for testworld

* fixed nft error tests

* po service using generic service (#623)

* added testworld tests for proofs

* po service uses generic service

* removed old po tests

* P2P review updates (#624)

* P2P review updates

* review comments

* review comments

* Final rename

* P2P - tenant <--> protocol mapping (#626)

* NFT: fix async testcase  (#628)

* added testworld tests for proofs

* async nft testcase

*  Support local tenant loops (#627)

* P2P - tenant <--> protocol mapping

* Support local tenant loops

* Add tests

* Fix test

* Fix test

* Review comments

* Add basic Read rules to CoreDocument (#611)

This PR will add basic read rules derived from the collaborators passed.

Fixes #587

* identity: gocelery task for successful transaction (#632)

* added testworld tests for proofs

* added transaction status task

* added protobuf header transaction.

* removed nft confirm task

* implemented getTransactionStatus

* formatting

* formatting

* removed testoutput

* formatting

* added swagger

* Fix p2p validation check for local (#634)

* Fix p2p validation check for local

* Fix p2p validation check for local

* Added Generic handler + new p2p envelope (#629)

* envelope + handler

* rename proto

* format + tests

* timeout

* fix

* address comments

* Fix storage <--> config cycles (#633)

* Fix storage <--> config cycles

* Fix test

* Fix lint

* merge issues

* merge issues

* add peer validator for Read ACL (#639)

* add peer validator

* refactor to bool

* API /config/tenants/generate endpoint (#637)

* API /config/tenants/generate endpoint

* Fix problems

* Fix test issues

* Fix test issues

* Success message added (#641)

* Success message added

* further user instructions for success message

* Added signature to header + handshake validation (#640)

* Added signature to header + handshake validation

* fix tests

* address comments

* added eth key check

* fix integration test

* Multitenant(Account) api (#642)

* Enable auth header for API

* Minor

* Minor

* Minor

* More tests and fixes

* non exisiting document check

* Fix tests

* lint

* fix

* remove comment

* P2P Key check (#648)

* Added signature to header + handshake validation

* fix tests

* address comments

* added eth key check

* fix integration test

* Remove signature

* Remove signature

* typo

* fix pk

* Import main node config file everytime node starts(simpler than removing config service usage) (#649)

* Import main node config file everytime node starts(simpler than removing config service usage)

* Remove dead code

* Fix tests

* Fix test

* Fix problem with creat

* review comments

* add account fields to notification (#653)

* add account fields to notification

* comments + proto-gen

* Account rename 1: move API /config/tenants => /accounts (#654)

* move API /config/tenants => /accounts

* move API /config/tenants => /accounts

* Review comments

* added tests for transactionStatusTask (#645)

* added testworld tests for proofs

* added transaction status task

* added protobuf header transaction.

* removed nft confirm task

* implemented getTransactionStatus

* formatting

* formatting

* removed testoutput

* formatting

* added swagger

* added integration tests for transaction task

* formatting

* formatting

* removed mock eth client from identity package

* simplified integration tests

* changed nft register transactionTask

* fixed broken unit test in api package

* Add Auth Header to Swagger UI (#655)

* add account fields to notification

* comments + proto-gen

* Add custom swagger auth header

* comments

* use latest gocelery for retry and delay (#643)

Remove the for loop with retryable tasks

* Add nil safe config (#636)

* add nil safe config

* add error checks account config

* error type

* error type

*  Account rename 2: refs in config and configstore packages (#659)

* move API /config/tenants => /accounts

* move API /config/tenants => /accounts

* Review comments

* Account rename 2: refs in config and configstore packages

* merge

* Review comments

* More refs

* pump metis version (#657)

* removing confirmation transaction task (#658)

* added testworld tests for proofs

* added transaction status task

* added protobuf header transaction.

* removed nft confirm task

* implemented getTransactionStatus

* formatting

* formatting

* removed testoutput

* formatting

* added swagger

* added integration tests for transaction task

* formatting

* formatting

* removed mock eth client from identity package

* simplified integration tests

* changed nft register transactionTask

* fixed broken unit test in api package

* removing confirmation task

* transactionStatusTask: added submitTransaction to ethereum package (#661)

* created submitTransaction method

* create transactionTask queuing in ethereum package

* modified mock clients

* moved register transaction task  into ethereum package

* support getting core documents (#652)

* update MessageTypes to include GetAnchoredDocument type

* added generic service to Handler struct

* changed naming on messagetypes

* updated centrifuge-protobuf package to latest version

* implementation for GetDocument method

* resolve MessageType for GetDocument methods from string

* removed irrelevant senderID

* added genericService to p2p bootstrapper

* Feat/read acl nfts (#650)

Fixes #590 

This would add the NFT validator.

* remove the signature from NFT read acls (#664)

As per our discussion yesterday

* Refactor/message types to map (#662)

* if else block to map

* Account rename 3: use of tenant in variable names (#665)

* Account rename 3: use of tenant in variable names

* fix compile

* Document service refactor (#666)

* break the coredocument package

* fix anchors

* fix unit tests

* fix unit tests

* fix tests

* break the coredocument package

* fix anchors

* fix unit tests

* fix unit tests

* fix tests

* Client has access to idService (#667)

* Added CMD tests (#668)

* Added CMD tests

* wrap in go file
  • Loading branch information
mikiquantum authored Jan 20, 2019
1 parent f5c58aa commit d84a5a3
Show file tree
Hide file tree
Showing 255 changed files with 14,480 additions and 5,890 deletions.
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<This is intended as a guide when thinking about or creating issues for go-centrifuge>


#### Testing
<Describe required tests: Unit, Integration, Testworld or Functional>

#### Acceptance Criteria
<What is the acceptance criteria of this ticket?>

#### Dependencies and affected external components
<Outline any dependencies and components that could be affected by this>

### Bug reports

#### Expected behaviour


#### Actual behaviour


#### Steps to reproduce the behaviour

2 changes: 2 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<This is intended as a guide when describing-reviewing pull requests for go-centrifuge>
Issue Link: <Github link>
37 changes: 13 additions & 24 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ required = ["github.com/centrifuge/centrifuge-ethereum-contracts", "github.com/r

[[constraint]]
name = "github.com/centrifuge/centrifuge-protobufs"
revision = "34ce7eaff0b89ac4a34e60654d34297747e5a7b4"
revision = "f93686ceaf40283c7dc496c62fcc69b1c1a272e3"

[[override]]
name = "github.com/centrifuge/centrifuge-ethereum-contracts"
Expand All @@ -40,11 +40,11 @@ required = ["github.com/centrifuge/centrifuge-ethereum-contracts", "github.com/r

[[override]]
name = "github.com/centrifuge/precise-proofs"
revision = "d0df6e2ed059de47375ef8281529a500cd920261"
revision = "8c3b6a26b7929ec269302dc50d17c9ceb9772dda"

[[constraint]]
name = "github.com/centrifuge/gocelery"
revision = "80f35a18b9a0c632d7843e7e536873b0536f0040"
revision = "fb11151a227ae41660e15f6c10e2e22eb1556531"

[[override]]
name = "github.com/xsleonard/go-merkle"
Expand Down Expand Up @@ -214,11 +214,6 @@ required = ["github.com/centrifuge/centrifuge-ethereum-contracts", "github.com/r
name = "github.com/multiformats/go-multihash"
version = "1.0.8"

[[constraint]]
name = "github.com/paralin/go-libp2p-grpc"
source = "github.com/vedhavyas/go-libp2p-grpc"
revision = "04711f07389ecbca09d7999474dda4a88c955c73"

[[constraint]]
name = "github.com/spf13/cobra"
version = "0.0.3"
Expand All @@ -231,7 +226,7 @@ required = ["github.com/centrifuge/centrifuge-ethereum-contracts", "github.com/r
name = "github.com/stretchr/testify"
version = "1.2.2"

[[constraint]]
[[override]]
name = "github.com/syndtr/goleveldb"
revision = "ae2bd5eed72d46b28834ec3f60db3a3ebedd8dbd"

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ proto-all: ## runs prototool all
$(PROTOTOOL_BIN) all

gen-swagger: ## generates the swagger documentation
npm --prefix ./build run build_swagger
npm --prefix ./build run build_swagger

generate: ## autogenerate go files for config
go generate ./config/configuration.go
Expand Down
7 changes: 1 addition & 6 deletions anchors/anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ package anchors

import (
"math/big"

"github.com/centrifuge/go-centrifuge/errors"

"time"

"github.com/centrifuge/go-centrifuge/errors"
"github.com/centrifuge/go-centrifuge/identity"
"github.com/centrifuge/go-centrifuge/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)

Expand All @@ -32,9 +29,7 @@ type AnchorID [AnchorIDLength]byte

// Config defines required functions for the package Anchors
type Config interface {
GetEthereumDefaultAccountName() string
GetEthereumContextWaitTimeout() time.Duration
GetContractAddress(address string) common.Address
}

// ToAnchorID convert the bytes into AnchorID type
Expand Down
5 changes: 3 additions & 2 deletions anchors/anchor_repository.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package anchors

import (
"context"
"math/big"

"github.com/centrifuge/go-centrifuge/identity"
Expand All @@ -12,7 +13,7 @@ var log = logging.Logger("anchorRepository")
// AnchorRepository defines a set of functions that can be
// implemented by any type that stores and retrieves the anchoring, and pre anchoring details.
type AnchorRepository interface {
PreCommitAnchor(anchorID AnchorID, signingRoot DocumentRoot, centID identity.CentID, signature []byte, expirationBlock *big.Int) (<-chan *WatchPreCommit, error)
CommitAnchor(anchorID AnchorID, documentRoot DocumentRoot, centID identity.CentID, documentProofs [][32]byte, signature []byte) (<-chan *WatchCommit, error)
PreCommitAnchor(ctx context.Context, anchorID AnchorID, signingRoot DocumentRoot, centID identity.CentID, signature []byte, expirationBlock *big.Int) (confirmations <-chan *WatchPreCommit, err error)
CommitAnchor(ctx context.Context, anchorID AnchorID, documentRoot DocumentRoot, centID identity.CentID, documentProofs [][32]byte, signature []byte) (confirmations <-chan *WatchCommit, err error)
GetDocumentRootOf(anchorID AnchorID) (DocumentRoot, error)
}
20 changes: 15 additions & 5 deletions anchors/anchor_repository_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import (
"testing"

"github.com/centrifuge/go-centrifuge/anchors"
cc "github.com/centrifuge/go-centrifuge/context/testingbootstrap"
"github.com/centrifuge/go-centrifuge/bootstrap"
cc "github.com/centrifuge/go-centrifuge/bootstrap/bootstrappers/testingbootstrap"
"github.com/centrifuge/go-centrifuge/config"
"github.com/centrifuge/go-centrifuge/crypto/secp256k1"
"github.com/centrifuge/go-centrifuge/ethereum"
"github.com/centrifuge/go-centrifuge/identity"
"github.com/centrifuge/go-centrifuge/keytools/secp256k1"
"github.com/centrifuge/go-centrifuge/testingutils/config"
"github.com/centrifuge/go-centrifuge/utils"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/stretchr/testify/assert"
Expand All @@ -20,20 +23,23 @@ import (
var (
identityService identity.Service
anchorRepo anchors.AnchorRepository
cfg config.Configuration
)

func TestMain(m *testing.M) {
ctx := cc.TestFunctionalEthereumBootstrap()
anchorRepo = ctx[anchors.BootstrappedAnchorRepo].(anchors.AnchorRepository)
identityService = ctx[identity.BootstrappedIDService].(identity.Service)
cfg = ctx[bootstrap.BootstrappedConfig].(config.Configuration)
result := m.Run()
cc.TestFunctionalEthereumTearDown()
os.Exit(result)
}

func createIdentityWithKeys(t *testing.T, centrifugeId []byte) []byte {
centIdTyped, _ := identity.ToCentID(centrifugeId)
id, confirmations, err := identityService.CreateIdentity(centIdTyped)
cfg.Set("identityId", centIdTyped.String())
id, confirmations, err := identityService.CreateIdentity(testingconfig.CreateTenantContext(t, cfg), centIdTyped)
assert.Nil(t, err, "should not error out when creating identity")
watchRegisteredIdentity := <-confirmations
assert.Nil(t, watchRegisteredIdentity.Error, "No error thrown by context")
Expand Down Expand Up @@ -74,7 +80,9 @@ func commitAnchor(t *testing.T, anchorID, centrifugeId, documentRoot, signature
docRootTyped, _ := anchors.ToDocumentRoot(documentRoot)
centIdFixed, _ := identity.ToCentID(centrifugeId)

confirmations, err := anchorRepo.CommitAnchor(anchorIDTyped, docRootTyped, centIdFixed, documentProofs, signature)
cfg.Set("identityId", centIdFixed.String())
ctx := testingconfig.CreateTenantContext(t, cfg)
confirmations, err := anchorRepo.CommitAnchor(ctx, anchorIDTyped, docRootTyped, centIdFixed, documentProofs, signature)
if err != nil {
t.Fatalf("Error commit Anchor %v", err)
}
Expand Down Expand Up @@ -102,7 +110,9 @@ func TestCommitAnchor_Integration_Concurrent(t *testing.T) {
h, err := ethereum.GetClient().GetEthClient().HeaderByNumber(context.Background(), nil)
assert.Nil(t, err, " error must be nil")
commitDataList[ix] = anchors.NewCommitData(h.Number.Uint64(), currentAnchorId, currentDocumentRoot, centIdFixed, documentProofs, signature)
confirmationList[ix], err = anchorRepo.CommitAnchor(currentAnchorId, currentDocumentRoot, centIdFixed, documentProofs, signature)
cfg.Set("identityId", centIdFixed.String())
ctx := testingconfig.CreateTenantContext(t, cfg)
confirmationList[ix], err = anchorRepo.CommitAnchor(ctx, currentAnchorId, currentDocumentRoot, centIdFixed, documentProofs, signature)
if err != nil {
t.Fatalf("Error commit Anchor %v", err)
}
Expand Down
10 changes: 6 additions & 4 deletions anchors/bootstrapper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package anchors

import (
"github.com/centrifuge/go-centrifuge/config"
"github.com/centrifuge/go-centrifuge/config/configstore"
"github.com/centrifuge/go-centrifuge/errors"

"github.com/centrifuge/go-centrifuge/bootstrap"
Expand All @@ -17,17 +19,17 @@ type Bootstrapper struct{}
// Bootstrap initializes the anchorRepositoryContract as well as the anchorConfirmationTask that depends on it.
// the anchorConfirmationTask is added to be registered on the Queue at queue.Bootstrapper.
func (Bootstrapper) Bootstrap(ctx map[string]interface{}) error {
if _, ok := ctx[bootstrap.BootstrappedConfig]; !ok {
return errors.New("config hasn't been initialized")
cfg, err := configstore.RetrieveConfig(false, ctx)
if err != nil {
return err
}
cfg := ctx[bootstrap.BootstrappedConfig].(Config)

if _, ok := ctx[ethereum.BootstrappedEthereumClient]; !ok {
return errors.New("ethereum client hasn't been initialized")
}
client := ctx[ethereum.BootstrappedEthereumClient].(ethereum.Client)

repositoryContract, err := NewEthereumAnchorRepositoryContract(cfg.GetContractAddress("anchorRepository"), client.GetEthClient())
repositoryContract, err := NewEthereumAnchorRepositoryContract(cfg.GetContractAddress(config.AnchorRepo), client.GetEthClient())
if err != nil {
return err
}
Expand Down
20 changes: 16 additions & 4 deletions anchors/ethereum_anchor_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"math/big"

"github.com/centrifuge/go-centrifuge/contextutil"

"time"

"github.com/centrifuge/go-centrifuge/errors"
Expand Down Expand Up @@ -47,9 +49,14 @@ func (ethRepository *ethereumAnchorRepository) GetDocumentRootOf(anchorID Anchor
}

// PreCommitAnchor will call the transaction PreCommit on the smart contract
func (ethRepository *ethereumAnchorRepository) PreCommitAnchor(anchorID AnchorID, signingRoot DocumentRoot, centID identity.CentID, signature []byte, expirationBlock *big.Int) (confirmations <-chan *WatchPreCommit, err error) {
func (ethRepository *ethereumAnchorRepository) PreCommitAnchor(ctx context.Context, anchorID AnchorID, signingRoot DocumentRoot, centID identity.CentID, signature []byte, expirationBlock *big.Int) (confirmations <-chan *WatchPreCommit, err error) {
tc, err := contextutil.Account(ctx)
if err != nil {
return nil, err
}

ethRepositoryContract := ethRepository.anchorRepositoryContract
opts, err := ethereum.GetClient().GetTxOpts(ethRepository.config.GetEthereumDefaultAccountName())
opts, err := ethereum.GetClient().GetTxOpts(tc.GetEthereumDefaultAccountName())
if err != nil {
return confirmations, err
}
Expand All @@ -71,9 +78,14 @@ func (ethRepository *ethereumAnchorRepository) PreCommitAnchor(anchorID AnchorID
}

// CommitAnchor will send a commit transaction to Ethereum.
func (ethRepository *ethereumAnchorRepository) CommitAnchor(anchorID AnchorID, documentRoot DocumentRoot, centID identity.CentID, documentProofs [][32]byte, signature []byte) (confirmations <-chan *WatchCommit, err error) {
func (ethRepository *ethereumAnchorRepository) CommitAnchor(ctx context.Context, anchorID AnchorID, documentRoot DocumentRoot, centID identity.CentID, documentProofs [][32]byte, signature []byte) (confirmations <-chan *WatchCommit, err error) {
tc, err := contextutil.Account(ctx)
if err != nil {
return nil, err
}

conn := ethereum.GetClient()
opts, err := conn.GetTxOpts(ethRepository.config.GetEthereumDefaultAccountName())
opts, err := conn.GetTxOpts(tc.GetEthereumDefaultAccountName())
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion anchors/ethereum_anchor_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"math/big"
"testing"

"github.com/centrifuge/go-centrifuge/crypto/secp256k1"
"github.com/centrifuge/go-centrifuge/ethereum"
"github.com/centrifuge/go-centrifuge/identity"
"github.com/centrifuge/go-centrifuge/keytools/secp256k1"
"github.com/centrifuge/go-centrifuge/testingutils/commons"
"github.com/centrifuge/go-centrifuge/utils"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down
Loading

0 comments on commit d84a5a3

Please sign in to comment.