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

Add tests for Patricia Tree contract #16

Open
androlo opened this issue Sep 17, 2017 · 1 comment
Open

Add tests for Patricia Tree contract #16

androlo opened this issue Sep 17, 2017 · 1 comment
Assignees
Milestone

Comments

@androlo
Copy link
Collaborator

androlo commented Sep 17, 2017

No description provided.

@androlo androlo added this to the Beta release milestone Sep 17, 2017
@androlo androlo self-assigned this Sep 17, 2017
@maxrobot
Copy link

maxrobot commented Jul 6, 2018

Hi @androlo I have tried to add some tests for the Patricia tree contract. I am following the tests from go-ethereum/trie/trie_test.go, but have implemented it in JS.

My test is as follows:

  it('Test: Insert()', async () => {
    const patricia = await Patricia.new();
    const accounts = web3.eth.accounts;

    let insertReceipt = await patricia.insert("A", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

    // Get the root
    const rootReceipt = await patricia.getRootHash()
    const bytesRoot = hexToBytes(rootReceipt)
    
    const expectedRoot = hexToBytes("0xd23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab")
    assert.equal(expectedRoot, bytesRoot)
  })

The root produced is incorrect:
Root Expected: 0xd23786fb4a010da3ce639d66d5e904a11dbc02746d1ce25029e53290cabf28ab
Root Received: 0xe114ce969de5ac619a41bdb02ee5489d904389e803ca89461215a0b9a51528b5

Is this behaviour expected? I assume the implementation must be identical to that in go-ethereum...

Anyhow I will continue working at it :)

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

2 participants