commit 66c261d6926558f5a75b4780086cae11b622409e
parent 962506aa3a7ea19f973bb4150245da71bda9431c
Author: lash <dev@holbrook.no>
Date: Fri, 3 Feb 2023 15:04:44 +0000
Add period test
Diffstat:
10 files changed, 193 insertions(+), 7 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,6 @@
+*.pyc
+__pycache__
+build/
+dist/
+solidity/*.json
+solidity/*.bin
diff --git a/python/eth_faucet/data/EthFaucet.bin b/python/eth_faucet/data/EthFaucet.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061148d806100606000396000f3fe6080604052600436106100c8576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100815780638da5cb5b1461020c578063a91ee0dc14610237578063aa8c217c14610260578063cb10d59a1461028b578063d6eca01e146102b6578063de82efb4146102df576100cf565b806318cbbcfc146100d4578063271f88b4146100ff57806331a5995d1461013c57806363e4bff4146101675780637b103999146101a457806386fe212d146101cf576100cf565b366100cf57005b600080fd5b3480156100e057600080fd5b506100e961030a565b6040516100f69190610f44565b60405180910390f35b34801561010b57600080fd5b5061012660048036038101906101219190610f90565b61030f565b6040516101339190610f44565b60405180910390f35b34801561014857600080fd5b50610151610435565b60405161015e9190610f44565b60405180910390f35b34801561017357600080fd5b5061018e6004803603810190610189919061101b565b61043b565b60405161019b9190610f44565b60405180910390f35b3480156101b057600080fd5b506101b961049a565b6040516101c69190611057565b60405180910390f35b3480156101db57600080fd5b506101f660048036038101906101f19190610f90565b6104c0565b6040516102039190610f44565b60405180910390f35b34801561021857600080fd5b506102216105e6565b60405161022e9190611057565b60405180910390f35b34801561024357600080fd5b5061025e6004803603810190610259919061101b565b61060a565b005b34801561026c57600080fd5b506102756107a7565b6040516102829190610f44565b60405180910390f35b34801561029757600080fd5b506102a06107ad565b6040516102ad9190611057565b60405180910390f35b3480156102c257600080fd5b506102dd60048036038101906102d8919061101b565b6107d3565b005b3480156102eb57600080fd5b506102f4610970565b6040516103019190610f44565b60405180910390f35b600781565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610397906110cf565b60405180910390fd5b6000600460ff1660035416146103eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e29061113b565b60405180910390fd5b816004819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e6004546040516104239190610f44565b60405180910390a16004549050919050565b60035481565b6000610446826109cd565b508173ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f1935050505015801561048f573d6000803e3d6000fd5b506004549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b600060088210610505576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104fc906111a7565b60405180910390fd5b600060035483161461054c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054390611213565b60405180910390fd5b816003600082825417925050819055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516105d4929190611233565b60405180910390a26003549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610698576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161068f906110cf565b60405180910390fd5b6000600160ff1660035416146106e3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106da9061113b565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161079c929190611233565b60405180910390a250565b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610861576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610858906110cf565b60405180910390fd5b6000600260ff1660035416146108ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108a39061113b565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051610965929190611233565b60405180910390a250565b600061097b336109cd565b503373ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f193505050501580156109c4573d6000803e3d6000fd5b50600454905090565b60008073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a2f57610a2d82610a99565b505b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a9057610a8e82610cec565b505b60019050919050565b6000806060600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610ae89190611057565b6040516020818303038152906040527fc23697a8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610b7291906112cd565b6000604051808303816000865af19150503d8060008114610baf576040519150601f19603f3d011682016040523d82523d6000602084013e610bb4565b606091505b50809250819350505081610bfd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf490611330565b60405180910390fd5b60007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610c3557610c34611350565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610ce1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd8906113cb565b60405180910390fd5b600192505050919050565b6000806060600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610d3b9190611057565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610dc591906112cd565b6000604051808303816000865af19150503d8060008114610e02576040519150601f19603f3d011682016040523d82523d6000602084013e610e07565b606091505b50809250819350505081610eb857600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d6070600454604051610e759190610f44565b60405180910390a36040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eaf90611437565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa600454604051610f189190610f44565b60405180910390a3600192505050919050565b6000819050919050565b610f3e81610f2b565b82525050565b6000602082019050610f596000830184610f35565b92915050565b600080fd5b610f6d81610f2b565b8114610f7857600080fd5b50565b600081359050610f8a81610f64565b92915050565b600060208284031215610fa657610fa5610f5f565b5b6000610fb484828501610f7b565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610fe882610fbd565b9050919050565b610ff881610fdd565b811461100357600080fd5b50565b60008135905061101581610fef565b92915050565b60006020828403121561103157611030610f5f565b5b600061103f84828501611006565b91505092915050565b61105181610fdd565b82525050565b600060208201905061106c6000830184611048565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b60006110b9600d83611072565b91506110c482611083565b602082019050919050565b600060208201905081810360008301526110e8816110ac565b9050919050565b7f4552525f5345414c454400000000000000000000000000000000000000000000600082015250565b6000611125600a83611072565b9150611130826110ef565b602082019050919050565b6000602082019050818103600083015261115481611118565b9050919050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b6000611191601183611072565b915061119c8261115b565b602082019050919050565b600060208201905081810360008301526111c081611184565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b60006111fd601283611072565b9150611208826111c7565b602082019050919050565b6000602082019050818103600083015261122c816111f0565b9050919050565b60006040820190506112486000830185611048565b6112556020830184611048565b9392505050565b600081519050919050565b600081905092915050565b60005b83811015611290578082015181840152602081019050611275565b60008484015250505050565b60006112a78261125c565b6112b18185611267565b93506112c1818560208601611272565b80840191505092915050565b60006112d9828461129c565b915081905092915050565b7f4552525f504552494f445f4241434b454e445f4552524f520000000000000000600082015250565b600061131a601883611072565b9150611325826112e4565b602082019050919050565b600060208201905081810360008301526113498161130d565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f504552494f445f434845434b00000000000000000000000000000000600082015250565b60006113b5601083611072565b91506113c08261137f565b602082019050919050565b600060208201905081810360008301526113e4816113a8565b9050919050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b6000611421600c83611072565b915061142c826113eb565b602082019050919050565b6000602082019050818103600083015261145081611414565b905091905056fea2646970667358221220e7b3abbd7f0e0c36f23b53411d73a2696ba1d53b6a7992e8d32731363c906b0664736f6c63430008110033
-\ No newline at end of file
+608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506116d0806100606000396000f3fe6080604052600436106100c8576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100815780638da5cb5b1461020c578063a91ee0dc14610237578063aa8c217c14610260578063cb10d59a1461028b578063d6eca01e146102b6578063de82efb4146102df576100cf565b806318cbbcfc146100d4578063271f88b4146100ff57806331a5995d1461013c57806363e4bff4146101675780637b103999146101a457806386fe212d146101cf576100cf565b366100cf57005b600080fd5b3480156100e057600080fd5b506100e961030a565b6040516100f6919061111b565b60405180910390f35b34801561010b57600080fd5b5061012660048036038101906101219190611167565b61030f565b604051610133919061111b565b60405180910390f35b34801561014857600080fd5b50610151610435565b60405161015e919061111b565b60405180910390f35b34801561017357600080fd5b5061018e600480360381019061018991906111f2565b61043b565b60405161019b919061111b565b60405180910390f35b3480156101b057600080fd5b506101b96104a2565b6040516101c6919061122e565b60405180910390f35b3480156101db57600080fd5b506101f660048036038101906101f19190611167565b6104c8565b604051610203919061111b565b60405180910390f35b34801561021857600080fd5b506102216105ee565b60405161022e919061122e565b60405180910390f35b34801561024357600080fd5b5061025e600480360381019061025991906111f2565b610612565b005b34801561026c57600080fd5b506102756107af565b604051610282919061111b565b60405180910390f35b34801561029757600080fd5b506102a06107b5565b6040516102ad919061122e565b60405180910390f35b3480156102c257600080fd5b506102dd60048036038101906102d891906111f2565b6107db565b005b3480156102eb57600080fd5b506102f4610978565b604051610301919061111b565b60405180910390f35b600781565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610397906112a6565b60405180910390fd5b6000600460ff1660035416146103eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103e290611312565b60405180910390fd5b816004819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e600454604051610423919061111b565b60405180910390a16004549050919050565b60035481565b6000610446826109dd565b61044f57600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f19350505050158015610497573d6000803e3d6000fd5b506004549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60006008821061050d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105049061137e565b60405180910390fd5b6000600354831614610554576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054b906113ea565b60405180910390fd5b816003600082825417925050819055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516105dc92919061140a565b60405180910390a26003549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146106a0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610697906112a6565b60405180910390fd5b6000600160ff1660035416146106eb576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106e290611312565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516107a492919061140a565b60405180910390a250565b60045481565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610869576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610860906112a6565b60405180910390fd5b6000600260ff1660035416146108b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108ab90611312565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547fe4b3d0535ec4cfd7bbe7b41fc94f6ee6bd15e97724854e3c3db2beb336d23a95600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1660405161096d92919061140a565b60405180910390a250565b6000610983336109dd565b61098c57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f193505050501580156109d4573d6000803e3d6000fd5b50600454905090565b60008073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610a3f57610a3d82610aa9565b505b600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610aa057610a9e82610ec3565b505b60019050919050565b6000806060600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610af8919061122e565b6040516020818303038152906040527fc23697a8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610b8291906114a4565b6000604051808303816000865af19150503d8060008114610bbf576040519150601f19603f3d011682016040523d82523d6000602084013e610bc4565b606091505b50809250819350505081610c0d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c0490611507565b60405180910390fd5b60007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610c4557610c44611527565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191603610cf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce8906115a2565b60405180910390fd5b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610d3b919061122e565b6040516020818303038152906040527fb1a997ac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610dc591906114a4565b6000604051808303816000865af19150503d8060008114610e02576040519150601f19603f3d011682016040523d82523d6000602084013e610e07565b606091505b50809250819350505081610eb857600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d6070600454604051610e75919061111b565b60405180910390a36040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610eaf9061160e565b60405180910390fd5b600192505050919050565b6000806060600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610f12919061122e565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610f9c91906114a4565b6000604051808303816000865af19150503d8060008114610fd9576040519150601f19603f3d011682016040523d82523d6000602084013e610fde565b606091505b5080925081935050508161108f57600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f2a56a00a5c532c49314f19361f71cdca8a5d10fdcb42c3fa52800d13419d607060045460405161104c919061111b565b60405180910390a36040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110869061167a565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f45c201a59ac545000ead84f30b2db67da23353aa1d58ac522c48505412143ffa6004546040516110ef919061111b565b60405180910390a3600192505050919050565b6000819050919050565b61111581611102565b82525050565b6000602082019050611130600083018461110c565b92915050565b600080fd5b61114481611102565b811461114f57600080fd5b50565b6000813590506111618161113b565b92915050565b60006020828403121561117d5761117c611136565b5b600061118b84828501611152565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006111bf82611194565b9050919050565b6111cf816111b4565b81146111da57600080fd5b50565b6000813590506111ec816111c6565b92915050565b60006020828403121561120857611207611136565b5b6000611216848285016111dd565b91505092915050565b611228816111b4565b82525050565b6000602082019050611243600083018461121f565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000611290600d83611249565b915061129b8261125a565b602082019050919050565b600060208201905081810360008301526112bf81611283565b9050919050565b7f4552525f5345414c454400000000000000000000000000000000000000000000600082015250565b60006112fc600a83611249565b9150611307826112c6565b602082019050919050565b6000602082019050818103600083015261132b816112ef565b9050919050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b6000611368601183611249565b915061137382611332565b602082019050919050565b600060208201905081810360008301526113978161135b565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b60006113d4601283611249565b91506113df8261139e565b602082019050919050565b60006020820190508181036000830152611403816113c7565b9050919050565b600060408201905061141f600083018561121f565b61142c602083018461121f565b9392505050565b600081519050919050565b600081905092915050565b60005b8381101561146757808201518184015260208101905061144c565b60008484015250505050565b600061147e82611433565b611488818561143e565b9350611498818560208601611449565b80840191505092915050565b60006114b08284611473565b915081905092915050565b7f4552525f504552494f445f4241434b454e445f4552524f520000000000000000600082015250565b60006114f1601883611249565b91506114fc826114bb565b602082019050919050565b60006020820190508181036000830152611520816114e4565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f504552494f445f434845434b00000000000000000000000000000000600082015250565b600061158c601083611249565b915061159782611556565b602082019050919050565b600060208201905081810360008301526115bb8161157f565b9050919050565b7f4552525f504552494f445f434845434b5f524547495354455200000000000000600082015250565b60006115f8601983611249565b9150611603826115c2565b602082019050919050565b60006020820190508181036000830152611627816115eb565b9050919050565b7f4552525f5452414e534645520000000000000000000000000000000000000000600082015250565b6000611664600c83611249565b915061166f8261162e565b602082019050919050565b6000602082019050818103600083015261169381611657565b905091905056fea26469706673582212200878414bb7bfab20171d24f266b54ac0c03af4cfa8313f09e2ea9bb3fa3d268a64736f6c63430008110033
+\ No newline at end of file
diff --git a/python/eth_faucet/data/PeriodSimple.bin b/python/eth_faucet/data/PeriodSimple.bin
@@ -1 +1 @@
-608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506107c9806100c16000396000f3fe608060405234801561001057600080fd5b506004361061009a576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100785780638da5cb5b14610109578063b1a997ac14610127578063c23697a814610143578063ef78d4fd146101735761009a565b80630f3a9f651461009f5780634b6bdf1d146100bb5780634ee577b4146100d9575b600080fd5b6100b960048036038101906100b49190610499565b610191565b005b6100c3610229565b6040516100d09190610507565b60405180910390f35b6100f360048036038101906100ee919061054e565b61024f565b604051610100919061058a565b60405180910390f35b610111610267565b60405161011e9190610507565b60405180910390f35b610141600480360381019061013c919061054e565b61028b565b005b61015d6004803603810190610158919061054e565b610400565b60405161016a91906105c0565b60405180910390f35b61017b610458565b604051610188919061058a565b60405180910390f35b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161461021f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161021690610638565b60405180910390fd5b8060028190555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60036020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806103325750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610371576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610368906106a4565b60405180910390fd5b61037a81610400565b6103b9576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103b090610710565b60405180910390fd5b42600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b6000600254600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000205461044f919061075f565b42109050919050565b60025481565b600080fd5b6000819050919050565b61047681610463565b811461048157600080fd5b50565b6000813590506104938161046d565b92915050565b6000602082840312156104af576104ae61045e565b5b60006104bd84828501610484565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006104f1826104c6565b9050919050565b610501816104e6565b82525050565b600060208201905061051c60008301846104f8565b92915050565b61052b816104e6565b811461053657600080fd5b50565b60008135905061054881610522565b92915050565b6000602082840312156105645761056361045e565b5b600061057284828501610539565b91505092915050565b61058481610463565b82525050565b600060208201905061059f600083018461057b565b92915050565b60008115159050919050565b6105ba816105a5565b82525050565b60006020820190506105d560008301846105b1565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000610622600d836105db565b915061062d826105ec565b602082019050919050565b6000602082019050818103600083015261065181610615565b9050919050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b600061068e600a836105db565b915061069982610658565b602082019050919050565b600060208201905081810360008301526106bd81610681565b9050919050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b60006106fa600d836105db565b9150610705826106c4565b602082019050919050565b60006020820190508181036000830152610729816106ed565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061076a82610463565b915061077583610463565b925082820190508082111561078d5761078c610730565b5b9291505056fea2646970667358221220e4dde66325e75216a8f628405c6cf3dde4da48b21720174ad6a51f40b9e4b38764736f6c63430008110033
-\ No newline at end of file
+608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506108dc806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100a5576000357c010000000000000000000000000000000000000000000000000000000090048063b1a997ac11610078578063b1a997ac14610132578063c23697a81461014e578063ef78d4fd1461017e578063f4430dd81461019c576100a5565b80630f3a9f65146100aa5780634b6bdf1d146100c65780634ee577b4146100e45780638da5cb5b14610114575b600080fd5b6100c460048036038101906100bf91906105ac565b6101b8565b005b6100ce610250565b6040516100db919061061a565b60405180910390f35b6100fe60048036038101906100f99190610661565b610276565b60405161010b919061069d565b60405180910390f35b61011c61028e565b604051610129919061061a565b60405180910390f35b61014c60048036038101906101479190610661565b6102b2565b005b61016860048036038101906101639190610661565b610427565b60405161017591906106d3565b60405180910390f35b6101866104cf565b604051610193919061069d565b60405180910390f35b6101b660048036038101906101b19190610661565b6104d5565b005b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614610246576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161023d9061074b565b60405180910390fd5b8060028190555050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60036020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806103595750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610398576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161038f906107b7565b60405180910390fd5b6103a181610427565b6103e0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103d790610823565b60405180910390fd5b42600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555050565b600080600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020540361047857600190506104ca565b600254600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104c59190610872565b421190505b919050565b60025481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461052d57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080fd5b6000819050919050565b61058981610576565b811461059457600080fd5b50565b6000813590506105a681610580565b92915050565b6000602082840312156105c2576105c1610571565b5b60006105d084828501610597565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610604826105d9565b9050919050565b610614816105f9565b82525050565b600060208201905061062f600083018461060b565b92915050565b61063e816105f9565b811461064957600080fd5b50565b60008135905061065b81610635565b92915050565b60006020828403121561067757610676610571565b5b60006106858482850161064c565b91505092915050565b61069781610576565b82525050565b60006020820190506106b2600083018461068e565b92915050565b60008115159050919050565b6106cd816106b8565b82525050565b60006020820190506106e860008301846106c4565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000610735600d836106ee565b9150610740826106ff565b602082019050919050565b6000602082019050818103600083015261076481610728565b9050919050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b60006107a1600a836106ee565b91506107ac8261076b565b602082019050919050565b600060208201905081810360008301526107d081610794565b9050919050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b600061080d600d836106ee565b9150610818826107d7565b602082019050919050565b6000602082019050818103600083015261083c81610800565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061087d82610576565b915061088883610576565b92508282019050808211156108a05761089f610843565b5b9291505056fea26469706673582212203ed5c0c86394159ef741670b0b28eb5726fd98c9f413fc65ae7b7e36eb7cbd7264736f6c63430008110033
+\ No newline at end of file
diff --git a/python/eth_faucet/data/PeriodSimple.json b/python/eth_faucet/data/PeriodSimple.json
@@ -1 +1 @@
-[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"PeriodChange","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"check","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"period","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"poke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"setPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"}]
+[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"PeriodChange","type":"event"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"check","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lastUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"period","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"poke","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_period","type":"uint256"}],"name":"setPeriod","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_poker","type":"address"}],"name":"setPoker","outputs":[],"stateMutability":"nonpayable","type":"function"}]
diff --git a/python/eth_faucet/faucet.py b/python/eth_faucet/faucet.py
@@ -16,6 +16,7 @@ from chainlib.eth.contract import (
ABIContractEncoder,
ABIContractType,
)
+from chainlib.eth.tx import TxFormat
from erc20_faucet import Faucet
from hexathon import add_0x
@@ -61,3 +62,15 @@ class EthFaucet(Faucet):
tx = self.template(sender_address, None, use_nonce=True)
tx = self.set_code(tx, code)
return self.build(tx)
+
+
+ def set_period_checker(self, contract_address, sender_address, checker_address, tx_format=TxFormat.JSONRPC):
+ enc = ABIContractEncoder()
+ enc.method('setPeriodChecker')
+ enc.typ(ABIContractType.ADDRESS)
+ enc.address(checker_address)
+ data = enc.get()
+ tx = self.template(sender_address, contract_address, use_nonce=True)
+ tx = self.set_code(tx, data)
+ tx = self.finalize(tx, tx_format)
+ return tx
diff --git a/python/run_tests.sh b/python/run_tests.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+set -a
+set -e
+set -x
+default_pythonpath=$PYTHONPATH:.
+export PYTHONPATH=${default_pythonpath:-.}
+>&2 echo using pythonpath $PYTHONPATH
+for f in `ls tests/*.py`; do
+ python $f
+done
+set +x
+set +e
+set +a
diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py
@@ -41,7 +41,10 @@ class TestFaucet(EthTesterCase):
c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
(tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
self.conn.do(o)
-
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
o = balance(self.accounts[9])
r = self.conn.do(o)
prebalance = int(r, 16)
diff --git a/python/tests/test_period.py b/python/tests/test_period.py
@@ -0,0 +1,136 @@
+# standard imports
+import os
+import unittest
+import logging
+
+# external imports
+from chainlib.connection import RPCConnection
+from chainlib.eth.nonce import RPCNonceOracle
+from chainlib.eth.unittest.ethtester import EthTesterCase
+from chainlib.eth.tx import receipt
+from chainlib.eth.tx import TxFactory
+from chainlib.eth.address import to_checksum_address
+from chainlib.eth.gas import balance
+from chainlib.eth.gas import Gas
+from chainlib.eth.gas import OverrideGasOracle
+from chainlib.eth.contract import ABIContractEncoder
+from chainlib.eth.contract import ABIContractType
+from chainlib.eth.block import block_by_number
+
+# local imports
+from eth_faucet.faucet import EthFaucet
+
+logging.basicConfig(level=logging.DEBUG)
+logg = logging.getLogger()
+
+
+
+moddir = os.path.dirname(__file__)
+datadir = os.path.join(moddir, '..', 'eth_faucet', 'data')
+
+
+class TestFaucet(EthTesterCase):
+
+ def setUp(self):
+ super(TestFaucet, self).setUp()
+ # DRY
+ self.conn = RPCConnection.connect(self.chain_spec, 'default')
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+
+ f = open(os.path.join(datadir, 'PeriodSimple.bin'))
+ period_store_bytecode = f.read()
+ f.close()
+ enc = ABIContractEncoder()
+ code = enc.get()
+
+ c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ tx = c.template(self.accounts[0], None, use_nonce=True)
+ tx = c.set_code(tx, period_store_bytecode)
+ (tx_hash_hex, o) = c.build(tx)
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+ self.period_store_contract = r['contract_address']
+
+ o = block_by_number(r['block_number'])
+ r = self.conn.do(o)
+
+ try:
+ self.start_time = int(r['timestamp'], 16)
+ except TypeError:
+ self.start_time = int(r['timestamp'])
+
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.constructor(self.accounts[0])
+ r = self.conn.do(o)
+
+ o = receipt(r)
+ r = self.conn.do(o)
+ self.address = to_checksum_address(r['contract_address'])
+ logg.debug('faucet contract {}'.format(self.address))
+
+ (tx_hash_hex, o) = c.set_period_checker(self.address, self.accounts[0], self.period_store_contract)
+ self.conn.do(o)
+
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+
+ def test_period(self):
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+ c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ enc = ABIContractEncoder()
+ enc.method('setPeriod')
+ enc.typ(ABIContractType.UINT256)
+ enc.uint256(100)
+ data = enc.get()
+ tx = c.template(self.accounts[0], self.period_store_contract, use_nonce=True)
+ tx = c.set_code(tx, data)
+ (tx_hash_hex, o) = c.finalize(tx)
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+ c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ enc = ABIContractEncoder()
+ enc.method('setPoker')
+ enc.typ(ABIContractType.ADDRESS)
+ enc.address(self.address)
+ data = enc.get()
+ tx = c.template(self.accounts[0], self.period_store_contract, use_nonce=True)
+ tx = c.set_code(tx, data)
+ (tx_hash_hex, o) = c.finalize(tx)
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+ nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn)
+ c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle)
+ (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+ r = (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 0)
+
+ self.backend.time_travel(self.start_time + 6000)
+
+ r = (tx_hash_hex, o) = c.give_to(self.address, self.accounts[0], self.accounts[2])
+ self.conn.do(o)
+ o = receipt(tx_hash_hex)
+ r = self.conn.do(o)
+ self.assertEqual(r['status'], 1)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/solidity/EthFaucet.sol b/solidity/EthFaucet.sol
@@ -65,6 +65,12 @@ contract EthFacuet {
if (_result[31] == 0) {
revert('ERR_PERIOD_CHECK');
}
+
+ (_ok, _result) = periodChecker.call(abi.encodeWithSignature("poke(address)", _recipient));
+ if (!_ok) {
+ emit FaucetFail(_recipient, address(0), amount);
+ revert('ERR_PERIOD_CHECK_REGISTER');
+ }
return true;
}
diff --git a/solidity/PeriodSimple.sol b/solidity/PeriodSimple.sol
@@ -21,8 +21,16 @@ contract PeriodSimple {
period = _period;
}
+ function setPoker(address _poker) public {
+ require(msg.sender == owner);
+ poker = _poker;
+ }
+
function check(address _subject) public view returns(bool) {
- return block.timestamp < lastUsed[_subject] + period;
+ if (lastUsed[_subject] == 0) {
+ return true;
+ }
+ return block.timestamp > lastUsed[_subject] + period;
}
function poke(address _subject) public {