evm-tokenvote

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 137c886fa3dff809bcd6846a75661a718f87f407
parent adfe40abafcb1895e12f3d4c62d675e02d3fafbd
Author: lash <dev@holbrook.no>
Date:   Sat,  6 May 2023 23:29:47 +0100

Add missing test file, add registry tests

Diffstat:
Mpython/evm_tokenvote/data/Voter.bin | 4++--
Mpython/evm_tokenvote/data/Voter.metadata.json | 2+-
Mpython/evm_tokenvote/unittest/base.py | 47++++++++++++++++++++++++++++++++++++++++++++---
Apython/tests/test_registry.py | 75+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apython/tests/test_token.py | 162+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msolidity/Voter.sol | 8+++++++-
6 files changed, 291 insertions(+), 7 deletions(-)

diff --git a/python/evm_tokenvote/data/Voter.bin b/python/evm_tokenvote/data/Voter.bin @@ -1 +1 @@ -60806040523480156200001157600080fd5b5060405162003462380380620034628339818101604052810190620000379190620003da565b6200004162000217565b826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001819080600181540180825580915050600190039060005260206000209060070201600090919091909150600082015181600001556020820151816001019080519060200190620001169291906200028e565b50604082015181600201908051906020019062000135929190620002e0565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff1602179055505050600160038190555050505062000421565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b828054828255906000526020600020908101928215620002cd579160200282015b82811115620002cc578251825591602001919060010190620002af565b5b509050620002dc919062000332565b5090565b8280548282559060005260206000209081019282156200031f579160200282015b828111156200031e57825182559160200191906001019062000301565b5b5090506200032e919062000351565b5090565b5b808211156200034d57600081600090555060010162000333565b5090565b5b808211156200036c57600081600090555060010162000352565b5090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003a28262000375565b9050919050565b620003b48162000395565b8114620003c057600080fd5b50565b600081519050620003d481620003a9565b92915050565b60008060408385031215620003f457620003f362000370565b5b60006200040485828601620003c3565b92505060206200041785828601620003c3565b9150509250929050565b61303180620004316000396000f3fe608060405234801561001057600080fd5b5060043610610107576000357c01000000000000000000000000000000000000000000000000000000009004806384385191116100a9578063ba32941411610083578063ba329414146102b6578063c7f758a8146102e6578063e99a943e14610316578063fc0c546a1461034657610107565b806384385191146102265780638bb5221314610256578063b05c65ba1461028657610107565b806341ec6870116100e557806341ec68701461018a5780634bb278f3146101a8578063509bd337146101c657806370a08231146101f657610107565b80630121b93f1461010c5780631ce309271461013c5780633ccfd60b1461016c575b600080fd5b61012660048036038101906101219190611eb4565b610364565b6040516101339190611efc565b60405180910390f35b61015660048036038101906101519190611f17565b610378565b6040516101639190611f70565b60405180910390f35b6101746103d4565b6040516101819190611f9a565b60405180910390f35b61019261075d565b60405161019f919061228d565b60405180910390f35b6101b0610925565b6040516101bd9190611efc565b60405180910390f35b6101e060048036038101906101db9190611f17565b610af2565b6040516101ed9190611efc565b60405180910390f35b610210600480360381019061020b91906122db565b610fce565b60405161021d9190611f9a565b60405180910390f35b610240600480360381019061023b9190611eb4565b610fe6565b60405161024d9190611f9a565b60405180910390f35b610270600480360381019061026b9190612334565b611028565b60405161027d9190611efc565b60405180910390f35b6102a0600480360381019061029b9190612525565b6112dd565b6040516102ad9190611f9a565b60405180910390f35b6102d060048036038101906102cb9190611f17565b6115cb565b6040516102dd9190611f9a565b60405180910390f35b61030060048036038101906102fb9190611eb4565b611687565b60405161030d919061228d565b60405180910390f35b610330600480360381019061032b91906125a8565b61185a565b60405161033d9190611f9a565b60405180910390f35b61034e611874565b60405161035b919061260a565b60405180910390f35b6000610371600083610af2565b9050919050565b600080600180856103899190612654565b8154811061039a57610399612688565b5b906000526020600020906007020190508060010183815481106103c0576103bf612688565b5b906000526020600020015491505092915050565b600080600060606000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036105145760016003548154811061047d5761047c612688565b5b90600052602060002090600702019350438460050154116104f757600060028560060160179054906101000a900460ff161660ff16116104f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e990612714565b60405180910390fd5b610513565b8084600401600082825461050b9190612734565b925050819055505b5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1633826040516024016105e8929190612768565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516106729190612802565b6000604051808303816000865af19150503d80600081146106af576040519150601f19603f3d011682016040523d82523d6000602084013e6106b4565b606091505b508093508194505050826106fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f490612865565b60405180910390fd5b8180602001905181019061071191906128b1565b925082610753576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074a9061292a565b60405180910390fd5b8094505050505090565b610765611d1f565b60016003548154811061077b5761077a612688565b5b90600052602060002090600702016040518061014001604052908160008201548152602001600182018054806020026020016040519081016040528092919081815260200182805480156107ee57602002820191906000526020600020905b8154815260200190600101908083116107da575b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561084657602002820191906000526020600020905b815481526020019060010190808311610832575b505050505081526020016003820154815260200160048201548152602001600582015481526020016006820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016006820160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016006820160179054906101000a900460ff1660ff1660ff1681526020016006820160189054906101000a900460ff1660ff1660ff1681525050905090565b60008060006001600354815481106109405761093f612688565b5b90600052602060002090600702019150600060028360060160179054906101000a900460ff161660ff16146109aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109a190612996565b60405180910390fd5b600060048360060160179054906101000a900460ff161660ff1611610a04576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109fb90612a02565b60405180910390fd5b6000610a0f83611898565b03610a1f57600092505050610aef565b60028260060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600160036000828254610a629190612654565b92505081905550620f42408260040154610a7c9190612a22565b90508160060160009054906101000a900462ffffff1662ffffff16826003015482610aa79190612a93565b1015610ae85760088260060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600092505050610aef565b6001925050505b90565b60008060006060610b0233611b03565b600160035481548110610b1857610b17612688565b5b90600052602060002090600702019250600060018460060160179054906101000a900460ff161660ff1611610b82576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b7990612b10565b60405180910390fd5b6000610b8d84611898565b03610b9e5760009350505050610fc8565b43836005015411610be4576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bdb90612b7c565b60405180910390fd5b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610cb057600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610caf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ca690612be8565b60405180910390fd5b5b600083600101805490501115610d0a5782600101805490508610610d09576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d0090612c54565b60405180910390fd5b5b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16333087604051602401610d5693929190612cd3565b6040516020818303038152906040527f23b872dd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610de09190612802565b6000604051808303816000865af19150503d8060008114610e1d576040519150601f19603f3d011682016040523d82523d6000602084013e610e22565b606091505b50809250819350505081610e6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e6290612865565b60405180910390fd5b80806020019051810190610e7f91906128b1565b915081610ec1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eb89061292a565b60405180910390fd5b600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555084600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254610f569190612654565b9250508190555084836004016000828254610f719190612654565b92505081905550600083600101805490501115610fc05784836002018781548110610f9f57610f9e612688565b5b906000526020600020016000828254610fb89190612654565b925050819055505b600193505050505b92915050565b60046020528060005260406000206000915090505481565b60008060018084610ff79190612654565b8154811061100857611007612688565b5b906000526020600020906007020190508060010180549050915050919050565b6000806000806000806000806001808b6110429190612654565b8154811061105357611052612688565b5b9060005260206000209060070201965043876005015411156110aa576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110a190612714565b60405180910390fd5b600060048860060160179054906101000a900460ff161660ff1611156110da5760009750505050505050506112d7565b60008760010180549050036111295760048760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060019750505050505050506112d7565b8660060160189054906101000a900460ff169150866001018054905089836111519190612d0a565b60ff1611156111705781876001018054905061116d9190612d3f565b98505b818961117c9190612d0a565b98508660060160179054906101000a900460ff1690508195505b8860ff168660ff16101561122557866002018660ff16815481106111bd576111bc612688565b5b906000526020600020015492506000831180156111d957508383145b156111e957601081179050611203565b83831115611202578293508560ff169450601019811690505b5b6001826112109190612d0a565b9150858061121d90612d74565b965050611196565b818760060160186101000a81548160ff021916908360ff160217905550808760060160176101000a81548160ff021916908360ff16021790555086600101805490508760060160189054906101000a900460ff1660ff16106112b25760048760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055505b600060048860060160179054906101000a900460ff161660ff16119750505050505050505b92915050565b60006112e7611d1f565b60008061010087511061132f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161132690612de9565b60405180910390fd5b338360e0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505087836000018181525050868360200181905250865167ffffffffffffffff811115611395576113946123b6565b5b6040519080825280602002602001820160405280156113c35781602001602082028036833780820191505090505b508360400181905250848360c0019062ffffff16908162ffffff168152505085436113ee9190612654565b9050808360a00181815250506001805490509150600183610100019060ff16908160ff16815250506001839080600181540180825580915050600190039060005260206000209060070201600090919091909150600082015181600001556020820151816001019080519060200190611468929190611d96565b506040820151816002019080519060200190611485929190611de3565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff16021790555050506115806001838154811061156d5761156c612688565b5b9060005260206000209060070201611898565b836060018181525050818562ffffff16827f5a41400aa51d78e9e5ca645b0d045817eaa7d90e4344d773fdbe24ffb183d3ce60405160405180910390a4819350505050949350505050565b600080600180856115dc9190612654565b815481106115ed576115ec612688565b5b90600052602060002090600702019050600081600101805490500361165c576000831461164f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161164690612e55565b60405180910390fd5b8060040154915050611681565b80600201838154811061167257611671612688565b5b90600052602060002001549150505b92915050565b61168f611d1f565b6001808361169d9190612654565b815481106116ae576116ad612688565b5b906000526020600020906007020160405180610140016040529081600082015481526020016001820180548060200260200160405190810160405280929190818152602001828054801561172157602002820191906000526020600020905b81548152602001906001019080831161170d575b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561177957602002820191906000526020600020905b815481526020019060010190808311611765575b505050505081526020016003820154815260200160048201548152602001600582015481526020016006820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016006820160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016006820160179054906101000a900460ff1660ff1660ff1681526020016006820160189054906101000a900460ff1660ff1660ff16815250509050919050565b6000606061186a858286866112dd565b9150509392505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f18160ddd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516119679190612802565b6000604051808303816000865af19150503d80600081146119a4576040519150601f19603f3d011682016040523d82523d6000602084013e6119a9565b606091505b508093508194505050826119f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119e990612865565b60405180910390fd5b81806020019051810190611a069190612e8a565b905060008111611a4b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a4290612f03565b60405180910390fd5b6000856003015403611a6557808560030181905550611af7565b84600301548114611af65760208560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060028560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600160036000828254611ae39190612654565b9250508190555060009350505050611afe565b5b8093505050505b919050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603611b64575050611d1c565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1683604051602401611bae919061260a565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611c389190612802565b6000604051808303816000865af19150503d8060008114611c75576040519150601f19603f3d011682016040523d82523d6000602084013e611c7a565b606091505b50809250819350505081611cc3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611cba90612f6f565b60405180910390fd5b80806020019051810190611cd791906128b1565b915081611d19576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d1090612fdb565b60405180910390fd5b50505b50565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b828054828255906000526020600020908101928215611dd2579160200282015b82811115611dd1578251825591602001919060010190611db6565b5b509050611ddf9190611e30565b5090565b828054828255906000526020600020908101928215611e1f579160200282015b82811115611e1e578251825591602001919060010190611e03565b5b509050611e2c9190611e4d565b5090565b5b80821115611e49576000816000905550600101611e31565b5090565b5b80821115611e66576000816000905550600101611e4e565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b611e9181611e7e565b8114611e9c57600080fd5b50565b600081359050611eae81611e88565b92915050565b600060208284031215611eca57611ec9611e74565b5b6000611ed884828501611e9f565b91505092915050565b60008115159050919050565b611ef681611ee1565b82525050565b6000602082019050611f116000830184611eed565b92915050565b60008060408385031215611f2e57611f2d611e74565b5b6000611f3c85828601611e9f565b9250506020611f4d85828601611e9f565b9150509250929050565b6000819050919050565b611f6a81611f57565b82525050565b6000602082019050611f856000830184611f61565b92915050565b611f9481611e7e565b82525050565b6000602082019050611faf6000830184611f8b565b92915050565b611fbe81611f57565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000611ffc8383611fb5565b60208301905092915050565b6000602082019050919050565b600061202082611fc4565b61202a8185611fcf565b935061203583611fe0565b8060005b8381101561206657815161204d8882611ff0565b975061205883612008565b925050600181019050612039565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6120a881611e7e565b82525050565b60006120ba838361209f565b60208301905092915050565b6000602082019050919050565b60006120de82612073565b6120e8818561207e565b93506120f38361208f565b8060005b8381101561212457815161210b88826120ae565b9750612116836120c6565b9250506001810190506120f7565b5085935050505092915050565b600062ffffff82169050919050565b61214981612131565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061217a8261214f565b9050919050565b61218a8161216f565b82525050565b600060ff82169050919050565b6121a681612190565b82525050565b6000610140830160008301516121c56000860182611fb5565b50602083015184820360208601526121dd8282612015565b915050604083015184820360408601526121f782826120d3565b915050606083015161220c606086018261209f565b50608083015161221f608086018261209f565b5060a083015161223260a086018261209f565b5060c083015161224560c0860182612140565b5060e083015161225860e0860182612181565b5061010083015161226d61010086018261219d565b5061012083015161228261012086018261219d565b508091505092915050565b600060208201905081810360008301526122a781846121ac565b905092915050565b6122b88161216f565b81146122c357600080fd5b50565b6000813590506122d5816122af565b92915050565b6000602082840312156122f1576122f0611e74565b5b60006122ff848285016122c6565b91505092915050565b61231181612190565b811461231c57600080fd5b50565b60008135905061232e81612308565b92915050565b6000806040838503121561234b5761234a611e74565b5b600061235985828601611e9f565b925050602061236a8582860161231f565b9150509250929050565b61237d81611f57565b811461238857600080fd5b50565b60008135905061239a81612374565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6123ee826123a5565b810181811067ffffffffffffffff8211171561240d5761240c6123b6565b5b80604052505050565b6000612420611e6a565b905061242c82826123e5565b919050565b600067ffffffffffffffff82111561244c5761244b6123b6565b5b602082029050602081019050919050565b600080fd5b600061247561247084612431565b612416565b905080838252602082019050602084028301858111156124985761249761245d565b5b835b818110156124c157806124ad888261238b565b84526020840193505060208101905061249a565b5050509392505050565b600082601f8301126124e0576124df6123a0565b5b81356124f0848260208601612462565b91505092915050565b61250281612131565b811461250d57600080fd5b50565b60008135905061251f816124f9565b92915050565b6000806000806080858703121561253f5761253e611e74565b5b600061254d8782880161238b565b945050602085013567ffffffffffffffff81111561256e5761256d611e79565b5b61257a878288016124cb565b935050604061258b87828801611e9f565b925050606061259c87828801612510565b91505092959194509250565b6000806000606084860312156125c1576125c0611e74565b5b60006125cf8682870161238b565b93505060206125e086828701611e9f565b92505060406125f186828701612510565b9150509250925092565b6126048161216f565b82525050565b600060208201905061261f60008301846125fb565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061265f82611e7e565b915061266a83611e7e565b925082820190508082111561268257612681612625565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082825260208201905092915050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b60006126fe600d836126b7565b9150612709826126c8565b602082019050919050565b6000602082019050818103600083015261272d816126f1565b9050919050565b600061273f82611e7e565b915061274a83611e7e565b925082820390508181111561276257612761612625565b5b92915050565b600060408201905061277d60008301856125fb565b61278a6020830184611f8b565b9392505050565b600081519050919050565b600081905092915050565b60005b838110156127c55780820151818401526020810190506127aa565b60008484015250505050565b60006127dc82612791565b6127e6818561279c565b93506127f68185602086016127a7565b80840191505092915050565b600061280e82846127d1565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b600061284f6009836126b7565b915061285a82612819565b602082019050919050565b6000602082019050818103600083015261287e81612842565b9050919050565b61288e81611ee1565b811461289957600080fd5b50565b6000815190506128ab81612885565b92915050565b6000602082840312156128c7576128c6611e74565b5b60006128d58482850161289c565b91505092915050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b6000612914600c836126b7565b915061291f826128de565b602082019050919050565b6000602082019050818103600083015261294381612907565b9050919050565b7f4552525f414c52454144595f53544154455f46494e414c000000000000000000600082015250565b60006129806017836126b7565b915061298b8261294a565b602082019050919050565b600060208201905081810360008301526129af81612973565b9050919050565b7f4552525f5343414e5f4649525354000000000000000000000000000000000000600082015250565b60006129ec600e836126b7565b91506129f7826129b6565b602082019050919050565b60006020820190508181036000830152612a1b816129df565b9050919050565b6000612a2d82611e7e565b9150612a3883611e7e565b9250828202612a4681611e7e565b91508282048414831517612a5d57612a5c612625565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000612a9e82611e7e565b9150612aa983611e7e565b925082612ab957612ab8612a64565b5b828204905092915050565b7f4552525f50524f504f53414c5f494e4143544956450000000000000000000000600082015250565b6000612afa6015836126b7565b9150612b0582612ac4565b602082019050919050565b60006020820190508181036000830152612b2981612aed565b9050919050565b7f4552525f444541444c494e450000000000000000000000000000000000000000600082015250565b6000612b66600c836126b7565b9150612b7182612b30565b602082019050919050565b60006020820190508181036000830152612b9581612b59565b9050919050565b7f4552525f57495448445241575f46495253540000000000000000000000000000600082015250565b6000612bd26012836126b7565b9150612bdd82612b9c565b602082019050919050565b60006020820190508181036000830152612c0181612bc5565b9050919050565b7f4552525f4f5054494f4e5f494e56414c49440000000000000000000000000000600082015250565b6000612c3e6012836126b7565b9150612c4982612c08565b602082019050919050565b60006020820190508181036000830152612c6d81612c31565b9050919050565b6000819050919050565b6000612c99612c94612c8f8461214f565b612c74565b61214f565b9050919050565b6000612cab82612c7e565b9050919050565b6000612cbd82612ca0565b9050919050565b612ccd81612cb2565b82525050565b6000606082019050612ce860008301866125fb565b612cf56020830185612cc4565b612d026040830184611f8b565b949350505050565b6000612d1582612190565b9150612d2083612190565b9250828201905060ff811115612d3957612d38612625565b5b92915050565b6000612d4a82612190565b9150612d5583612190565b9250828203905060ff811115612d6e57612d6d612625565b5b92915050565b6000612d7f82612190565b915060ff8203612d9257612d91612625565b5b600182019050919050565b7f4552525f544f4f5f4d414e595f4f5054494f4e53000000000000000000000000600082015250565b6000612dd36014836126b7565b9150612dde82612d9d565b602082019050919050565b60006020820190508181036000830152612e0281612dc6565b9050919050565b7f4552525f4e4f5f4f5054494f4e53000000000000000000000000000000000000600082015250565b6000612e3f600e836126b7565b9150612e4a82612e09565b602082019050919050565b60006020820190508181036000830152612e6e81612e32565b9050919050565b600081519050612e8481611e88565b92915050565b600060208284031215612ea057612e9f611e74565b5b6000612eae84828501612e75565b91505092915050565b7f4552525f5a45524f5f535550504c590000000000000000000000000000000000600082015250565b6000612eed600f836126b7565b9150612ef882612eb7565b602082019050919050565b60006020820190508181036000830152612f1c81612ee0565b9050919050565b7f4552525f52454749535452590000000000000000000000000000000000000000600082015250565b6000612f59600c836126b7565b9150612f6482612f23565b602082019050919050565b60006020820190508181036000830152612f8881612f4c565b9050919050565b7f4552525f554e415554485f4143434f554e540000000000000000000000000000600082015250565b6000612fc56012836126b7565b9150612fd082612f8f565b602082019050919050565b60006020820190508181036000830152612ff481612fb8565b905091905056fea2646970667358221220e0ac8b8530e66cb0154ad0c08cea9c35cbca0f543a8c43077c2421988beaeb9a64736f6c63430008130033 -\ No newline at end of file +60806040523480156200001157600080fd5b50604051620031e2380380620031e28339818101604052810190620000379190620003da565b6200004162000217565b826000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555081600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506001819080600181540180825580915050600190039060005260206000209060070201600090919091909150600082015181600001556020820151816001019080519060200190620001169291906200028e565b50604082015181600201908051906020019062000135929190620002e0565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff1602179055505050600160038190555050505062000421565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b828054828255906000526020600020908101928215620002cd579160200282015b82811115620002cc578251825591602001919060010190620002af565b5b509050620002dc919062000332565b5090565b8280548282559060005260206000209081019282156200031f579160200282015b828111156200031e57825182559160200191906001019062000301565b5b5090506200032e919062000351565b5090565b5b808211156200034d57600081600090555060010162000333565b5090565b5b808211156200036c57600081600090555060010162000352565b5090565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000620003a28262000375565b9050919050565b620003b48162000395565b8114620003c057600080fd5b50565b600081519050620003d481620003a9565b92915050565b60008060408385031215620003f457620003f362000370565b5b60006200040485828601620003c3565b92505060206200041785828601620003c3565b9150509250929050565b612db180620004316000396000f3fe608060405234801561001057600080fd5b5060043610610107576000357c01000000000000000000000000000000000000000000000000000000009004806384385191116100a9578063ba32941411610083578063ba329414146102b6578063c7f758a8146102e6578063e99a943e14610316578063fc0c546a1461034657610107565b806384385191146102265780638bb5221314610256578063b05c65ba1461028657610107565b806341ec6870116100e557806341ec68701461018a5780634bb278f3146101a8578063509bd337146101c657806370a08231146101f657610107565b80630121b93f1461010c5780631ce309271461013c5780633ccfd60b1461016c575b600080fd5b61012660048036038101906101219190611c5e565b610364565b6040516101339190611ca6565b60405180910390f35b61015660048036038101906101519190611cc1565b610378565b6040516101639190611d1a565b60405180910390f35b6101746103d4565b6040516101819190611d44565b60405180910390f35b61019261075d565b60405161019f9190612037565b60405180910390f35b6101b0610985565b6040516101bd9190611ca6565b60405180910390f35b6101e060048036038101906101db9190611cc1565b610b52565b6040516101ed9190611ca6565b60405180910390f35b610210600480360381019061020b9190612085565b610d78565b60405161021d9190611d44565b60405180910390f35b610240600480360381019061023b9190611c5e565b610d90565b60405161024d9190611d44565b60405180910390f35b610270600480360381019061026b91906120de565b610dd2565b60405161027d9190611ca6565b60405180910390f35b6102a0600480360381019061029b91906122cf565b611087565b6040516102ad9190611d44565b60405180910390f35b6102d060048036038101906102cb9190611cc1565b611375565b6040516102dd9190611d44565b60405180910390f35b61030060048036038101906102fb9190611c5e565b611431565b60405161030d9190612037565b60405180910390f35b610330600480360381019061032b9190612352565b611604565b60405161033d9190611d44565b60405180910390f35b61034e61161e565b60405161035b91906123b4565b60405180910390f35b6000610371600083610b52565b9050919050565b6000806001808561038991906123fe565b8154811061039a57610399612432565b5b906000526020600020906007020190508060010183815481106103c0576103bf612432565b5b906000526020600020015491505092915050565b600080600060606000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036105145760016003548154811061047d5761047c612432565b5b90600052602060002090600702019350438460050154116104f757600060028560060160179054906101000a900460ff161660ff16116104f2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104e9906124be565b60405180910390fd5b610513565b8084600401600082825461050b91906124de565b925050819055505b5b6000600460003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055506000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1633826040516024016105e8929190612512565b6040516020818303038152906040527fa9059cbb000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161067291906125ac565b6000604051808303816000865af19150503d80600081146106af576040519150601f19603f3d011682016040523d82523d6000602084013e6106b4565b606091505b508093508194505050826106fd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106f49061260f565b60405180910390fd5b81806020019051810190610711919061265b565b925082610753576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074a906126d4565b60405180910390fd5b8094505050505090565b610765611ac9565b600060016003548154811061077d5761077c612432565b5b90600052602060002090600702019050600060018260060160179054906101000a900460ff161660ff16116107e7576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107de90612740565b60405180910390fd5b8060405180610140016040529081600082015481526020016001820180548060200260200160405190810160405280929190818152602001828054801561084d57602002820191906000526020600020905b815481526020019060010190808311610839575b50505050508152602001600282018054806020026020016040519081016040528092919081815260200182805480156108a557602002820191906000526020600020905b815481526020019060010190808311610891575b505050505081526020016003820154815260200160048201548152602001600582015481526020016006820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016006820160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016006820160179054906101000a900460ff1660ff1660ff1681526020016006820160189054906101000a900460ff1660ff1660ff168152505091505090565b60008060006001600354815481106109a05761099f612432565b5b90600052602060002090600702019150600060028360060160179054906101000a900460ff161660ff1614610a0a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a01906127ac565b60405180910390fd5b600060048360060160179054906101000a900460ff161660ff1611610a64576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a5b90612818565b60405180910390fd5b6000610a6f83611642565b03610a7f57600092505050610b4f565b60028260060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600160036000828254610ac291906123fe565b92505081905550620f42408260040154610adc9190612838565b90508160060160009054906101000a900462ffffff1662ffffff16826003015482610b0791906128a9565b1015610b485760088260060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff160217905550600092505050610b4f565b6001925050505b90565b60008060006060610b62336118ad565b600160035481548110610b7857610b77612432565b5b90600052602060002090600702019250600060018460060160179054906101000a900460ff161660ff1611610be2576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd990612926565b60405180910390fd5b6000610bed84611642565b03610bfe5760009350505050610d72565b43836005015411610c44576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c3b90612992565b60405180910390fd5b6000600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020541115610d1057600354600560003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205414610d0f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d06906129fe565b60405180910390fd5b5b600083600101805490501115610d6a5782600101805490508610610d69576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6090612a6a565b60405180910390fd5b5b600093505050505b92915050565b60046020528060005260406000206000915090505481565b60008060018084610da191906123fe565b81548110610db257610db1612432565b5b906000526020600020906007020190508060010180549050915050919050565b6000806000806000806000806001808b610dec91906123fe565b81548110610dfd57610dfc612432565b5b906000526020600020906007020196504387600501541115610e54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e4b906124be565b60405180910390fd5b600060048860060160179054906101000a900460ff161660ff161115610e84576000975050505050505050611081565b6000876001018054905003610ed35760048760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055506001975050505050505050611081565b8660060160189054906101000a900460ff16915086600101805490508983610efb9190612a8a565b60ff161115610f1a57818760010180549050610f179190612abf565b98505b8189610f269190612a8a565b98508660060160179054906101000a900460ff1690508195505b8860ff168660ff161015610fcf57866002018660ff1681548110610f6757610f66612432565b5b90600052602060002001549250600083118015610f8357508383145b15610f9357601081179050610fad565b83831115610fac578293508560ff169450601019811690505b5b600182610fba9190612a8a565b91508580610fc790612af4565b965050610f40565b818760060160186101000a81548160ff021916908360ff160217905550808760060160176101000a81548160ff021916908360ff16021790555086600101805490508760060160189054906101000a900460ff1660ff161061105c5760048760060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff1602179055505b600060048860060160179054906101000a900460ff161660ff16119750505050505050505b92915050565b6000611091611ac9565b6000806101008751106110d9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110d090612b69565b60405180910390fd5b338360e0019073ffffffffffffffffffffffffffffffffffffffff16908173ffffffffffffffffffffffffffffffffffffffff168152505087836000018181525050868360200181905250865167ffffffffffffffff81111561113f5761113e612160565b5b60405190808252806020026020018201604052801561116d5781602001602082028036833780820191505090505b508360400181905250848360c0019062ffffff16908162ffffff1681525050854361119891906123fe565b9050808360a00181815250506001805490509150600183610100019060ff16908160ff16815250506001839080600181540180825580915050600190039060005260206000209060070201600090919091909150600082015181600001556020820151816001019080519060200190611212929190611b40565b50604082015181600201908051906020019061122f929190611b8d565b50606082015181600301556080820151816004015560a0820151816005015560c08201518160060160006101000a81548162ffffff021916908362ffffff16021790555060e08201518160060160036101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506101008201518160060160176101000a81548160ff021916908360ff1602179055506101208201518160060160186101000a81548160ff021916908360ff160217905550505061132a6001838154811061131757611316612432565b5b9060005260206000209060070201611642565b836060018181525050818562ffffff16827f5a41400aa51d78e9e5ca645b0d045817eaa7d90e4344d773fdbe24ffb183d3ce60405160405180910390a4819350505050949350505050565b6000806001808561138691906123fe565b8154811061139757611396612432565b5b90600052602060002090600702019050600081600101805490500361140657600083146113f9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113f090612bd5565b60405180910390fd5b806004015491505061142b565b80600201838154811061141c5761141b612432565b5b90600052602060002001549150505b92915050565b611439611ac9565b6001808361144791906123fe565b8154811061145857611457612432565b5b90600052602060002090600702016040518061014001604052908160008201548152602001600182018054806020026020016040519081016040528092919081815260200182805480156114cb57602002820191906000526020600020905b8154815260200190600101908083116114b7575b505050505081526020016002820180548060200260200160405190810160405280929190818152602001828054801561152357602002820191906000526020600020905b81548152602001906001019080831161150f575b505050505081526020016003820154815260200160048201548152602001600582015481526020016006820160009054906101000a900462ffffff1662ffffff1662ffffff1681526020016006820160039054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016006820160179054906101000a900460ff1660ff1660ff1681526020016006820160189054906101000a900460ff1660ff1660ff16815250509050919050565b6000606061161485828686611087565b9150509392505050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600080606060008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166040516024016040516020818303038152906040527f18160ddd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff838183161783525050505060405161171191906125ac565b6000604051808303816000865af19150503d806000811461174e576040519150601f19603f3d011682016040523d82523d6000602084013e611753565b606091505b5080935081945050508261179c576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117939061260f565b60405180910390fd5b818060200190518101906117b09190612c0a565b9050600081116117f5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117ec90612c83565b60405180910390fd5b600085600301540361180f578085600301819055506118a1565b846003015481146118a05760208560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060028560060160178282829054906101000a900460ff161792506101000a81548160ff021916908360ff16021790555060016003600082825461188d91906123fe565b92505081905550600093505050506118a8565b5b8093505050505b919050565b60006060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff160361190e575050611ac6565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168360405160240161195891906123b4565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516119e291906125ac565b6000604051808303816000865af19150503d8060008114611a1f576040519150601f19603f3d011682016040523d82523d6000602084013e611a24565b606091505b50809250819350505081611a6d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611a6490612cef565b60405180910390fd5b80806020019051810190611a81919061265b565b915081611ac3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611aba90612d5b565b60405180910390fd5b50505b50565b604051806101400160405280600080191681526020016060815260200160608152602001600081526020016000815260200160008152602001600062ffffff168152602001600073ffffffffffffffffffffffffffffffffffffffff168152602001600060ff168152602001600060ff1681525090565b828054828255906000526020600020908101928215611b7c579160200282015b82811115611b7b578251825591602001919060010190611b60565b5b509050611b899190611bda565b5090565b828054828255906000526020600020908101928215611bc9579160200282015b82811115611bc8578251825591602001919060010190611bad565b5b509050611bd69190611bf7565b5090565b5b80821115611bf3576000816000905550600101611bdb565b5090565b5b80821115611c10576000816000905550600101611bf8565b5090565b6000604051905090565b600080fd5b600080fd5b6000819050919050565b611c3b81611c28565b8114611c4657600080fd5b50565b600081359050611c5881611c32565b92915050565b600060208284031215611c7457611c73611c1e565b5b6000611c8284828501611c49565b91505092915050565b60008115159050919050565b611ca081611c8b565b82525050565b6000602082019050611cbb6000830184611c97565b92915050565b60008060408385031215611cd857611cd7611c1e565b5b6000611ce685828601611c49565b9250506020611cf785828601611c49565b9150509250929050565b6000819050919050565b611d1481611d01565b82525050565b6000602082019050611d2f6000830184611d0b565b92915050565b611d3e81611c28565b82525050565b6000602082019050611d596000830184611d35565b92915050565b611d6881611d01565b82525050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b6000611da68383611d5f565b60208301905092915050565b6000602082019050919050565b6000611dca82611d6e565b611dd48185611d79565b9350611ddf83611d8a565b8060005b83811015611e10578151611df78882611d9a565b9750611e0283611db2565b925050600181019050611de3565b5085935050505092915050565b600081519050919050565b600082825260208201905092915050565b6000819050602082019050919050565b611e5281611c28565b82525050565b6000611e648383611e49565b60208301905092915050565b6000602082019050919050565b6000611e8882611e1d565b611e928185611e28565b9350611e9d83611e39565b8060005b83811015611ece578151611eb58882611e58565b9750611ec083611e70565b925050600181019050611ea1565b5085935050505092915050565b600062ffffff82169050919050565b611ef381611edb565b82525050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611f2482611ef9565b9050919050565b611f3481611f19565b82525050565b600060ff82169050919050565b611f5081611f3a565b82525050565b600061014083016000830151611f6f6000860182611d5f565b5060208301518482036020860152611f878282611dbf565b91505060408301518482036040860152611fa18282611e7d565b9150506060830151611fb66060860182611e49565b506080830151611fc96080860182611e49565b5060a0830151611fdc60a0860182611e49565b5060c0830151611fef60c0860182611eea565b5060e083015161200260e0860182611f2b565b50610100830151612017610100860182611f47565b5061012083015161202c610120860182611f47565b508091505092915050565b600060208201905081810360008301526120518184611f56565b905092915050565b61206281611f19565b811461206d57600080fd5b50565b60008135905061207f81612059565b92915050565b60006020828403121561209b5761209a611c1e565b5b60006120a984828501612070565b91505092915050565b6120bb81611f3a565b81146120c657600080fd5b50565b6000813590506120d8816120b2565b92915050565b600080604083850312156120f5576120f4611c1e565b5b600061210385828601611c49565b9250506020612114858286016120c9565b9150509250929050565b61212781611d01565b811461213257600080fd5b50565b6000813590506121448161211e565b92915050565b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6121988261214f565b810181811067ffffffffffffffff821117156121b7576121b6612160565b5b80604052505050565b60006121ca611c14565b90506121d6828261218f565b919050565b600067ffffffffffffffff8211156121f6576121f5612160565b5b602082029050602081019050919050565b600080fd5b600061221f61221a846121db565b6121c0565b9050808382526020820190506020840283018581111561224257612241612207565b5b835b8181101561226b57806122578882612135565b845260208401935050602081019050612244565b5050509392505050565b600082601f83011261228a5761228961214a565b5b813561229a84826020860161220c565b91505092915050565b6122ac81611edb565b81146122b757600080fd5b50565b6000813590506122c9816122a3565b92915050565b600080600080608085870312156122e9576122e8611c1e565b5b60006122f787828801612135565b945050602085013567ffffffffffffffff81111561231857612317611c23565b5b61232487828801612275565b935050604061233587828801611c49565b9250506060612346878288016122ba565b91505092959194509250565b60008060006060848603121561236b5761236a611c1e565b5b600061237986828701612135565b935050602061238a86828701611c49565b925050604061239b868287016122ba565b9150509250925092565b6123ae81611f19565b82525050565b60006020820190506123c960008301846123a5565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061240982611c28565b915061241483611c28565b925082820190508082111561242c5761242b6123cf565b5b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b600082825260208201905092915050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b60006124a8600d83612461565b91506124b382612472565b602082019050919050565b600060208201905081810360008301526124d78161249b565b9050919050565b60006124e982611c28565b91506124f483611c28565b925082820390508181111561250c5761250b6123cf565b5b92915050565b600060408201905061252760008301856123a5565b6125346020830184611d35565b9392505050565b600081519050919050565b600081905092915050565b60005b8381101561256f578082015181840152602081019050612554565b60008484015250505050565b60006125868261253b565b6125908185612546565b93506125a0818560208601612551565b80840191505092915050565b60006125b8828461257b565b915081905092915050565b7f4552525f544f4b454e0000000000000000000000000000000000000000000000600082015250565b60006125f9600983612461565b9150612604826125c3565b602082019050919050565b60006020820190508181036000830152612628816125ec565b9050919050565b61263881611c8b565b811461264357600080fd5b50565b6000815190506126558161262f565b92915050565b60006020828403121561267157612670611c1e565b5b600061267f84828501612646565b91505092915050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b60006126be600c83612461565b91506126c982612688565b602082019050919050565b600060208201905081810360008301526126ed816126b1565b9050919050565b7f4552525f4e4f5f43555252454e545f50524f504f53414c000000000000000000600082015250565b600061272a601783612461565b9150612735826126f4565b602082019050919050565b600060208201905081810360008301526127598161271d565b9050919050565b7f4552525f414c52454144595f53544154455f46494e414c000000000000000000600082015250565b6000612796601783612461565b91506127a182612760565b602082019050919050565b600060208201905081810360008301526127c581612789565b9050919050565b7f4552525f5343414e5f4649525354000000000000000000000000000000000000600082015250565b6000612802600e83612461565b915061280d826127cc565b602082019050919050565b60006020820190508181036000830152612831816127f5565b9050919050565b600061284382611c28565b915061284e83611c28565b925082820261285c81611c28565b91508282048414831517612873576128726123cf565b5b5092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006128b482611c28565b91506128bf83611c28565b9250826128cf576128ce61287a565b5b828204905092915050565b7f4552525f50524f504f53414c5f494e4143544956450000000000000000000000600082015250565b6000612910601583612461565b915061291b826128da565b602082019050919050565b6000602082019050818103600083015261293f81612903565b9050919050565b7f4552525f444541444c494e450000000000000000000000000000000000000000600082015250565b600061297c600c83612461565b915061298782612946565b602082019050919050565b600060208201905081810360008301526129ab8161296f565b9050919050565b7f4552525f57495448445241575f46495253540000000000000000000000000000600082015250565b60006129e8601283612461565b91506129f3826129b2565b602082019050919050565b60006020820190508181036000830152612a17816129db565b9050919050565b7f4552525f4f5054494f4e5f494e56414c49440000000000000000000000000000600082015250565b6000612a54601283612461565b9150612a5f82612a1e565b602082019050919050565b60006020820190508181036000830152612a8381612a47565b9050919050565b6000612a9582611f3a565b9150612aa083611f3a565b9250828201905060ff811115612ab957612ab86123cf565b5b92915050565b6000612aca82611f3a565b9150612ad583611f3a565b9250828203905060ff811115612aee57612aed6123cf565b5b92915050565b6000612aff82611f3a565b915060ff8203612b1257612b116123cf565b5b600182019050919050565b7f4552525f544f4f5f4d414e595f4f5054494f4e53000000000000000000000000600082015250565b6000612b53601483612461565b9150612b5e82612b1d565b602082019050919050565b60006020820190508181036000830152612b8281612b46565b9050919050565b7f4552525f4e4f5f4f5054494f4e53000000000000000000000000000000000000600082015250565b6000612bbf600e83612461565b9150612bca82612b89565b602082019050919050565b60006020820190508181036000830152612bee81612bb2565b9050919050565b600081519050612c0481611c32565b92915050565b600060208284031215612c2057612c1f611c1e565b5b6000612c2e84828501612bf5565b91505092915050565b7f4552525f5a45524f5f535550504c590000000000000000000000000000000000600082015250565b6000612c6d600f83612461565b9150612c7882612c37565b602082019050919050565b60006020820190508181036000830152612c9c81612c60565b9050919050565b7f4552525f52454749535452590000000000000000000000000000000000000000600082015250565b6000612cd9600c83612461565b9150612ce482612ca3565b602082019050919050565b60006020820190508181036000830152612d0881612ccc565b9050919050565b7f4552525f554e415554485f4143434f554e540000000000000000000000000000600082015250565b6000612d45601283612461565b9150612d5082612d0f565b602082019050919050565b60006020820190508181036000830152612d7481612d38565b905091905056fea264697066735822122021c845d3414c772f201703623e2c70f90c40b7fee17c9a3bda7ec3226a13717764736f6c63430008130033 +\ No newline at end of file diff --git a/python/evm_tokenvote/data/Voter.metadata.json b/python/evm_tokenvote/data/Voter.metadata.json @@ -1 +1 @@ -{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accountsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_blockDeadline","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"voteTargetPpm","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"ProposalAdded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentProposal","outputs":[{"components":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"bytes32[]","name":"options","type":"bytes32[]"},{"internalType":"uint256[]","name":"optionVotes","type":"uint256[]"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"internalType":"struct ERC20Vote.Proposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"},{"internalType":"uint256","name":"_optionIdx","type":"uint256"}],"name":"getOption","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"getProposal","outputs":[{"components":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"bytes32[]","name":"options","type":"bytes32[]"},{"internalType":"uint256[]","name":"optionVotes","type":"uint256[]"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"internalType":"struct ERC20Vote.Proposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"optionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"propose","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"bytes32[]","name":"_options","type":"bytes32[]"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"proposeMulti","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIndex","type":"uint256"},{"internalType":"uint8","name":"_count","type":"uint8"}],"name":"scan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"vote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"},{"internalType":"uint256","name":"_optionIdx","type":"uint256"}],"name":"voteCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_optionIndex","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"voteOption","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Voter.sol":"ERC20Vote"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Voter.sol":{"keccak256":"0x2486775bc9c84d2ebdef107cd36ca0a851609d7d312feb5a240f95006fe6199e","license":"AGPL-3.0-or-later","urls":["bzz-raw://3ce2c237dc2374a2bde9367b3f74bed26125ecb8d75362e7f255fe7a244ce89d","dweb:/ipfs/Qmc8E3D15f2cFnDM3BfMB3SK2qKUfQp932hDU41Y9C35GF"]}},"version":1} +{"compiler":{"version":"0.8.19+commit.7dd6d404"},"language":"Solidity","output":{"abi":[{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_accountsRegistry","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_blockDeadline","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"voteTargetPpm","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"ProposalAdded","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalize","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getCurrentProposal","outputs":[{"components":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"bytes32[]","name":"options","type":"bytes32[]"},{"internalType":"uint256[]","name":"optionVotes","type":"uint256[]"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"internalType":"struct ERC20Vote.Proposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"},{"internalType":"uint256","name":"_optionIdx","type":"uint256"}],"name":"getOption","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"getProposal","outputs":[{"components":[{"internalType":"bytes32","name":"description","type":"bytes32"},{"internalType":"bytes32[]","name":"options","type":"bytes32[]"},{"internalType":"uint256[]","name":"optionVotes","type":"uint256[]"},{"internalType":"uint256","name":"supply","type":"uint256"},{"internalType":"uint256","name":"total","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"},{"internalType":"uint24","name":"targetVotePpm","type":"uint24"},{"internalType":"address","name":"proposer","type":"address"},{"internalType":"uint8","name":"state","type":"uint8"},{"internalType":"uint8","name":"scanCursor","type":"uint8"}],"internalType":"struct ERC20Vote.Proposal","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"}],"name":"optionCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"propose","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_description","type":"bytes32"},{"internalType":"bytes32[]","name":"_options","type":"bytes32[]"},{"internalType":"uint256","name":"_blockWait","type":"uint256"},{"internalType":"uint24","name":"_targetVotePpm","type":"uint24"}],"name":"proposeMulti","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIndex","type":"uint256"},{"internalType":"uint8","name":"_count","type":"uint8"}],"name":"scan","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"vote","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_proposalIdx","type":"uint256"},{"internalType":"uint256","name":"_optionIdx","type":"uint256"}],"name":"voteCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_optionIndex","type":"uint256"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"voteOption","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"Voter.sol":"ERC20Vote"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"Voter.sol":{"keccak256":"0xcd7a9f6b466b3184e4d1b9da1c3cf609671a15b1e1b80fbbc99ad5cd2df68c4b","license":"AGPL-3.0-or-later","urls":["bzz-raw://36552a6eb4fda47281fbbe799effa3dab8b2b19b0192013bb02786a0fb579bab","dweb:/ipfs/QmeMcXym3Ms3E9eNJmaabiicEukJiM4ifBFTzprVNW7Ano"]}},"version":1} diff --git a/python/evm_tokenvote/unittest/base.py b/python/evm_tokenvote/unittest/base.py @@ -12,6 +12,8 @@ from giftable_erc20_token.unittest import TestGiftableToken #from giftable_erc20_token import GiftableToken from eth_erc20 import ERC20 from chainlib.eth.block import block_latest +from eth_accounts_index.unittest import TestAccountsIndex +from eth_accounts_index.registry import AccountRegistry # local imports from evm_tokenvote import Voter @@ -23,12 +25,12 @@ hash_of_bar = 'fcde2b2edba56bf408601fb721fe9b5c338d10ee429ea04fae5511b68fbf8fb9' hash_of_baz = 'baa5a0964d3320fbc0c6a922140453c8513ea24ab8fd0577034804a967248096' -class TestEvmVote(TestGiftableToken): +class TestEvmVoteAccounts(TestGiftableToken): expire = 0 def setUp(self): - super(TestEvmVote, self).setUp() + super(TestEvmVoteAccounts, self).setUp() self.alice = self.accounts[1] self.bob = self.accounts[2] @@ -45,7 +47,13 @@ class TestEvmVote(TestGiftableToken): r = self.rpc.do(o) self.supply = int(r, 16) self.assertGreater(self.supply, 0) - + + +class TestEvmVote(TestEvmVoteAccounts): + + def setUp(self): + super(TestEvmVote, self).setUp() + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) (tx_hash, o) = c.constructor(self.accounts[0], self.address) @@ -72,3 +80,36 @@ class TestEvmVoteProposal(TestEvmVote): o = block_latest() self.proposal_block_height = self.rpc.do(o) + + + +class TestEvmVoteRegistry(TestEvmVoteAccounts): + + def setUp(self): + super(TestEvmVoteRegistry, self).setUp() + + self.token_address = self.address + + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) + c = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.constructor(self.accounts[0]) + self.conn.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.registry_address = r['contract_address'] + logg.debug('published with accounts registry contract address {}'.format(r['contract_address'])) + + (tx_hash, o) = c.add_writer(self.registry_address, self.accounts[0], self.accounts[0]) + self.conn.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.constructor(self.accounts[0], self.token_address, accounts_registry_address=self.registry_address) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + self.voter_address = to_checksum_address(r['contract_address']) + logg.debug('published voter on address {} with hash {}'.format(self.voter_address, tx_hash)) diff --git a/python/tests/test_registry.py b/python/tests/test_registry.py @@ -0,0 +1,75 @@ +# standard imports +import unittest +import logging +import os +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.tx import receipt +from chainlib.eth.block import block_latest +from hexathon import same as same_hex +from eth_erc20 import ERC20 +from giftable_erc20_token import GiftableToken +from eth_accounts_index import AccountsIndex + +# local imports +from evm_tokenvote.unittest import TestEvmVoteRegistry +from evm_tokenvote.unittest.base import hash_of_foo +from evm_tokenvote import Voter +from evm_tokenvote import ProposalState + + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + + +class TestVoteRegistry(TestEvmVoteRegistry): + + def test_accounts_registry_vote(self): + half_supply = self.initial_supply / 2 + description = hash_of_foo + nonce_oracle = RPCNonceOracle(self.ivan, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.propose(self.voter_address, self.ivan, description, 100) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.transfer(self.address, self.accounts[0], self.alice, half_supply) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.approve(self.address, self.alice, self.voter_address, 100) + self.rpc.do(o) + + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.vote(self.voter_address, self.alice, half_supply - 1) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 0) + + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) + c = AccountsIndex(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.add(self.registry_address, self.accounts[0], self.alice) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.vote(self.voter_address, self.alice, half_supply) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/test_token.py b/python/tests/test_token.py @@ -0,0 +1,162 @@ +# standard imports +import unittest +import logging +import os +from chainlib.eth.nonce import RPCNonceOracle +from chainlib.eth.tx import receipt +from chainlib.eth.block import block_latest +from hexathon import same as same_hex +from eth_erc20 import ERC20 +from giftable_erc20_token import GiftableToken + +# local imports +from evm_tokenvote.unittest import TestEvmVoteProposal +from evm_tokenvote.unittest.base import hash_of_foo +from evm_tokenvote import Voter +from evm_tokenvote import ProposalState + + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + + +class TestVoteToken(TestEvmVoteProposal): + + def test_withdraw(self): + c = Voter(self.chain_spec) + o = c.get_proposal(self.voter_address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + proposal = c.parse_proposal(r) + + half_supply = self.initial_supply / 2 + nonce_oracle = RPCNonceOracle(self.accounts[0], conn=self.conn) + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.transfer(self.address, self.accounts[0], self.alice, half_supply) + self.rpc.do(o) + + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.approve(self.address, self.alice, self.voter_address, half_supply) + self.rpc.do(o) + + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.vote(self.voter_address, self.alice, half_supply) + self.rpc.do(o) + + c = ERC20(self.chain_spec) + o = c.balance_of(self.voter_address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, half_supply) + + o = c.balance_of(self.address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, 0) + + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.withdraw(self.voter_address, self.alice) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + o = c.balance_of(self.voter_address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, 0) + + o = c.balance_of(self.address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, half_supply) + + c = Voter(self.chain_spec) + o = c.get_proposal(self.voter_address, 0, sender_address=self.alice) + r = self.rpc.do(o) + proposal = c.parse_proposal(r) + self.assertEqual(proposal.total, 0) + + c = ERC20(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.approve(self.address, self.alice, self.voter_address, half_supply) + self.rpc.do(o) + + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.vote(self.voter_address, self.alice, half_supply) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + o = block_latest() + now_block_height = self.rpc.do(o) + need_blocks = self.proposal_block_height + 100 - now_block_height + 1 + self.backend.mine_blocks(need_blocks) + + # after deadline withdraw is locked + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.withdraw(self.voter_address, self.alice) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 0) + + o = c.get_proposal(self.voter_address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + proposal = c.parse_proposal(r) + self.assertEqual(proposal.total, half_supply) + + c = ERC20(self.chain_spec) + o = c.balance_of(self.voter_address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, half_supply) + + o = c.balance_of(self.address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, 0) + + # scan + finalize unlocks tokens + nonce_oracle = RPCNonceOracle(self.trent, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.scan(self.voter_address, self.trent, 0, 0) + self.rpc.do(o) + + (tx_hash, o) = c.finalize_vote(self.voter_address, self.trent) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + nonce_oracle = RPCNonceOracle(self.alice, conn=self.conn) + c = Voter(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + o = c.get_proposal(self.voter_address, 0, sender_address=self.accounts[0]) + r = self.rpc.do(o) + proposal = c.parse_proposal(r) + self.assertEqual(proposal.total, half_supply) + + (tx_hash, o) = c.withdraw(self.voter_address, self.alice) + self.rpc.do(o) + o = receipt(tx_hash) + r = self.rpc.do(o) + self.assertEqual(r['status'], 1) + + c = ERC20(self.chain_spec) + o = c.balance_of(self.address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, half_supply) + + o = c.balance_of(self.voter_address, self.alice, sender_address=self.accounts[0]) + r = self.rpc.do(o) + balance = int(r, 16) + self.assertEqual(balance, 0) + + + +if __name__ == '__main__': + unittest.main() diff --git a/solidity/Voter.sol b/solidity/Voter.sol @@ -72,12 +72,18 @@ contract ERC20Vote { return l_proposalIndex; } + // get proposal by index function getProposal(uint256 _proposalIdx) public view returns(Proposal memory) { return proposals[_proposalIdx + 1]; } + // get currently active proposal function getCurrentProposal() public view returns(Proposal memory) { - return proposals[currentProposal]; + Proposal storage proposal; + + proposal = proposals[currentProposal]; + require(proposal.state & STATE_INIT > 0, "ERR_NO_CURRENT_PROPOSAL"); + return proposal; } function propose(bytes32 _description, uint256 _blockWait, uint24 _targetVotePpm) public returns (uint256) {