Skip to content
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

Refactor Overall Test Structure #110

Closed
terencechain opened this issue May 9, 2018 · 4 comments
Closed

Refactor Overall Test Structure #110

terencechain opened this issue May 9, 2018 · 4 comments
Assignees

Comments

@terencechain
Copy link
Member

terencechain commented May 9, 2018

Context

To efficiently maintain all our tests, I am creating this issue to discuss the state of our current tests and how we can refactor them to be better. There's a lot of reusable test code that can ported to a test helper/util like file. Then we can re-use the test helper functions to avoid repeatable code tests

Current test structure:

  • contracts
    • sharding_manager_test.go
  • notary
    • notary_test.go
  • proposer
    • proposer_test.go
  • collation_test.go
  • config_test.go

What I propose:

  • contracts
    • contract_tests
      • notary_registration_test.go
      • notary_vote_test.go
      • proposer_add_header_test.go
  • notary
    • notary_test.go
  • proposer
    • proposer_test.go
  • collation
    • collation_test.go
  • config_test.go
  • test_utils
    • test_config.go
    • test_library.go

Test version of config

Similar to config.go we should have a test version of config naming test_config.go The config will have shorter notary and proposer lock up period. The current notary lock up period is 16128 periods. To deregister a notary takes 30 seconds with simulated backend, this won't scale for testing multiple notaries.

Test library

The test library has the following functions

// register 10 notaries, start 0 end 9
func (s *SMC) Batch_register_notary(start int, end int) error {}
// deregister the last 5 notaries, start 4 end 9
func (s *SMC) Batch_deregister_notary(start int, end int) error {}
// fast forward 100 periods
func (s *SMC) Fast_forward_period(p int) error {}
// add header from shard 0 to shard 100, start 0 end 99
func (s *SMC) Batch_add_header(start int, end int) error {}
// notary 0-9 votes on shard 10, start 0, end 9, shardId 10
func (s *SMC) Batch_submit_vote(start int, end int, shardId int) error {}
// Hash returns the hash of a collation's entire contents
func (c *Collation) Hash() (hash common.Hash) {}
@terencechain terencechain self-assigned this May 9, 2018
@prestonvanloon
Copy link
Member

prestonvanloon commented May 9, 2018

This is more about reorganizing into smaller packages?

I am 100% against tests not living next to the file they are testing. Can you update your proposal with the library files too?

@terencechain
Copy link
Member Author

The tests will live next to the file they are testing. I've updated the proposal with library files

@prestonvanloon
Copy link
Member

@terenc3t is this still something you are working on? Could you shine a bit more light on the details of implementation?

@rauljordan rauljordan changed the title Refactor overall test structure Refactor Overall Test Structure May 25, 2018
@terencechain
Copy link
Member Author

Do we want to move these occurring helper/setup methods (mockNode, transactOpts(), setup()) to a common sharding testing package? If not, we can close this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants