eth-faucet

Gas token gifter with controls from time intervals, amounts and access
Log | Files | Refs

commit 2c77976df8b165cf74e901ef469115ede4a560c9
parent 89b10e3192f64c63a640be54e3be5eb7c7df568c
Author: lash <dev@holbrook.no>
Date:   Fri, 24 Mar 2023 16:09:04 +0000

Fix inverted balance check in period, faucet main

Diffstat:
Mpython/eth_faucet/data/EthFaucet.bin | 4++--
Mpython/eth_faucet/data/EthFaucet.metadata.json | 2+-
Mpython/eth_faucet/data/PeriodSimple.bin | 4++--
Mpython/eth_faucet/data/PeriodSimple.metadata.json | 2+-
Apython/eth_faucet/unittest/__init__.py | 1+
Apython/eth_faucet/unittest/base.py | 190+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/setup.cfg | 2+-
Mpython/tests/test_basic.py | 34+++++++++-------------------------
Apython/tests/test_check.py | 82+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpython/tests/test_period.py | 112+++++++------------------------------------------------------------------------
Mpython/tests/test_registry.py | 46++--------------------------------------------
Msolidity/EthFaucet.sol | 2+-
Msolidity/PeriodSimple.sol | 8++++++--
13 files changed, 307 insertions(+), 182 deletions(-)

diff --git a/python/eth_faucet/data/EthFaucet.bin b/python/eth_faucet/data/EthFaucet.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611d27806100606000396000f3fe608060405260043610610109576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100a7578063d6eca01e11610076578063d6eca01e14610346578063de82efb41461036f578063eec7faa11461039a578063fc0c546a146103c557610110565b80638da5cb5b1461028a578063a91ee0dc146102b5578063c23697a8146102de578063cb10d59a1461031b57610110565b80633b1bd134116100e35780633b1bd134146101a857806363e4bff4146101e55780637b1039991461022257806386fe212d1461024d57610110565b806318cbbcfc14610115578063271f88b41461014057806331a5995d1461017d57610110565b3661011057005b600080fd5b34801561012157600080fd5b5061012a6103f0565b60405161013791906115be565b60405180910390f35b34801561014c57600080fd5b506101676004803603810190610162919061160a565b6103f5565b60405161017491906115be565b60405180910390f35b34801561018957600080fd5b5061019261051b565b60405161019f91906115be565b60405180910390f35b3480156101b457600080fd5b506101cf60048036038101906101ca9190611695565b610521565b6040516101dc91906115be565b60405180910390f35b3480156101f157600080fd5b5061020c60048036038101906102079190611695565b61069c565b60405161021991906115be565b60405180910390f35b34801561022e57600080fd5b5061023761076b565b60405161024491906116d1565b60405180910390f35b34801561025957600080fd5b50610274600480360381019061026f919061160a565b610791565b60405161028191906115be565b60405180910390f35b34801561029657600080fd5b5061029f6108b7565b6040516102ac91906116d1565b60405180910390f35b3480156102c157600080fd5b506102dc60048036038101906102d79190611695565b6108db565b005b3480156102ea57600080fd5b5061030560048036038101906103009190611695565b610a78565b6040516103129190611707565b60405180910390f35b34801561032757600080fd5b50610330610ab6565b60405161033d91906116d1565b60405180910390f35b34801561035257600080fd5b5061036d60048036038101906103689190611695565b610adc565b005b34801561037b57600080fd5b50610384610c79565b60405161039191906115be565b60405180910390f35b3480156103a657600080fd5b506103af610d46565b6040516103bc91906115be565b60405180910390f35b3480156103d157600080fd5b506103da610d50565b6040516103e791906116d1565b60405180910390f35b600781565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610486576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047d9061177f565b60405180910390fd5b6000600460ff1660035416146104d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c8906117eb565b60405180910390fd5b816004819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e60045460405161050991906115be565b60405180910390a16004549050919050565b60035481565b6000806060600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161057091906116d1565b6040516020818303038152906040527fab73e316000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105fa919061187c565b6000604051808303816000865af19150503d8060008114610637576040519150601f19603f3d011682016040523d82523d6000602084013e61063c565b606091505b50809250819350505081610685576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067c906118df565b60405180910390fd5b8061068f9061193e565b6001900492505050919050565b60006106a782610d55565b6106b057600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f193505050501580156106f8573d6000803e3d6000fd5b50600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f26162814817e23ec5035d6a2edc6c422da2da2119e27cfca6be65cc2dc55ca4c60045460405161075991906115be565b60405180910390a36004549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600882106107d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cd906119f1565b60405180910390fd5b600060035483161461081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611a5d565b60405180910390fd5b816003600082825417925050819055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516108a5929190611a7d565b60405180910390a26003549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610969576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109609061177f565b60405180910390fd5b6000600160ff1660035416146109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ab906117eb565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051610a6d929190611a7d565b60405180910390a250565b6000610a8382611099565b610a905760009050610ab1565b610a998261130d565b610aa65760009050610ab1565b610aae611581565b90505b919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b619061177f565b60405180910390fd5b6000600260ff166003541614610bb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bac906117eb565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051610c6e929190611a7d565b60405180910390a250565b6000610c8433610d55565b610c8d57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f19350505050158015610cd5573d6000803e3d6000fd5b50600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f26162814817e23ec5035d6a2edc6c422da2da2119e27cfca6be65cc2dc55ca4c600454604051610d3691906115be565b60405180910390a3600454905090565b6000600454905090565b600090565b6000806060610d62611581565b610da1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9890611af2565b60405180910390fd5b610daa8461130d565b610de9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de090611b5e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603610e4a57600192505050611094565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610e9491906116d1565b6040516020818303038152906040527fb1a997ac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610f1e919061187c565b6000604051808303816000865af19150503d8060008114610f5b576040519150601f19603f3d011682016040523d82523d6000602084013e610f60565b606091505b50809250819350505081610fa9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa090611bca565b60405180910390fd5b60007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610fe157610fe0611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361108d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108490611c65565b60405180910390fd5b6001925050505b919050565b6000806060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036110ff57600192505050611308565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161114991906116d1565b6040516020818303038152906040527fc23697a8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516111d3919061187c565b6000604051808303816000865af19150503d8060008114611210576040519150601f19603f3d011682016040523d82523d6000602084013e611215565b606091505b5080925081935050508161125e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125590611bca565b60405180910390fd5b60017f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061129657611295611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b919050565b6000806060600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036113735760019250505061157c565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016113bd91906116d1565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611447919061187c565b6000604051808303816000865af19150503d8060008114611484576040519150601f19603f3d011682016040523d82523d6000602084013e611489565b606091505b508092508193505050816114d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c990611cd1565b60405180910390fd5b60017f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061150a57611509611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b919050565b60003073ffffffffffffffffffffffffffffffffffffffff16316004541015905090565b6000819050919050565b6115b8816115a5565b82525050565b60006020820190506115d360008301846115af565b92915050565b600080fd5b6115e7816115a5565b81146115f257600080fd5b50565b600081359050611604816115de565b92915050565b6000602082840312156116205761161f6115d9565b5b600061162e848285016115f5565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061166282611637565b9050919050565b61167281611657565b811461167d57600080fd5b50565b60008135905061168f81611669565b92915050565b6000602082840312156116ab576116aa6115d9565b5b60006116b984828501611680565b91505092915050565b6116cb81611657565b82525050565b60006020820190506116e660008301846116c2565b92915050565b60008115159050919050565b611701816116ec565b82525050565b600060208201905061171c60008301846116f8565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000611769600d83611722565b915061177482611733565b602082019050919050565b600060208201905081810360008301526117988161175c565b9050919050565b7f4552525f5345414c454400000000000000000000000000000000000000000000600082015250565b60006117d5600a83611722565b91506117e08261179f565b602082019050919050565b60006020820190508181036000830152611804816117c8565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561183f578082015181840152602081019050611824565b60008484015250505050565b60006118568261180b565b6118608185611816565b9350611870818560208601611821565b80840191505092915050565b6000611888828461184b565b915081905092915050565b7f4552525f504552494f445f4241434b454e445f4552524f520000000000000000600082015250565b60006118c9601883611722565b91506118d482611893565b602082019050919050565b600060208201905081810360008301526118f8816118bc565b9050919050565b6000819050602082019050919050565b6000819050919050565b6000611925825161190f565b80915050919050565b60008160020a8302905092915050565b60006119498261180b565b82611953846118ff565b905061195e81611919565b9250602082101561199e576119997fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8360200360080261192e565b831692505b5050919050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b60006119db601183611722565b91506119e6826119a5565b602082019050919050565b60006020820190508181036000830152611a0a816119ce565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b6000611a47601283611722565b9150611a5282611a11565b602082019050919050565b60006020820190508181036000830152611a7681611a3a565b9050919050565b6000604082019050611a9260008301856116c2565b611a9f60208301846116c2565b9392505050565b7f4552525f494e53554646494349454e545f42414c414e43450000000000000000600082015250565b6000611adc601883611722565b9150611ae782611aa6565b602082019050919050565b60006020820190508181036000830152611b0b81611acf565b9050919050565b7f4552525f4e4f545f494e5f57484954454c495354000000000000000000000000600082015250565b6000611b48601483611722565b9150611b5382611b12565b602082019050919050565b60006020820190508181036000830152611b7781611b3b565b9050919050565b7f4552525f504552494f445f4241434b454e440000000000000000000000000000600082015250565b6000611bb4601283611722565b9150611bbf82611b7e565b602082019050919050565b60006020820190508181036000830152611be381611ba7565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f504552494f445f434845434b00000000000000000000000000000000600082015250565b6000611c4f601083611722565b9150611c5a82611c19565b602082019050919050565b60006020820190508181036000830152611c7e81611c42565b9050919050565b7f4552525f52454749535452595f4241434b454e44000000000000000000000000600082015250565b6000611cbb601483611722565b9150611cc682611c85565b602082019050919050565b60006020820190508181036000830152611cea81611cae565b905091905056fea2646970667358221220579622913630fb32ffc443938de91a6dfdc32ac2b68b5b2d775f44b115a76c8664736f6c63430008120033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550611d27806100606000396000f3fe608060405260043610610109576000357c0100000000000000000000000000000000000000000000000000000000900480638da5cb5b116100a7578063d6eca01e11610076578063d6eca01e14610346578063de82efb41461036f578063eec7faa11461039a578063fc0c546a146103c557610110565b80638da5cb5b1461028a578063a91ee0dc146102b5578063c23697a8146102de578063cb10d59a1461031b57610110565b80633b1bd134116100e35780633b1bd134146101a857806363e4bff4146101e55780637b1039991461022257806386fe212d1461024d57610110565b806318cbbcfc14610115578063271f88b41461014057806331a5995d1461017d57610110565b3661011057005b600080fd5b34801561012157600080fd5b5061012a6103f0565b60405161013791906115be565b60405180910390f35b34801561014c57600080fd5b506101676004803603810190610162919061160a565b6103f5565b60405161017491906115be565b60405180910390f35b34801561018957600080fd5b5061019261051b565b60405161019f91906115be565b60405180910390f35b3480156101b457600080fd5b506101cf60048036038101906101ca9190611695565b610521565b6040516101dc91906115be565b60405180910390f35b3480156101f157600080fd5b5061020c60048036038101906102079190611695565b61069c565b60405161021991906115be565b60405180910390f35b34801561022e57600080fd5b5061023761076b565b60405161024491906116d1565b60405180910390f35b34801561025957600080fd5b50610274600480360381019061026f919061160a565b610791565b60405161028191906115be565b60405180910390f35b34801561029657600080fd5b5061029f6108b7565b6040516102ac91906116d1565b60405180910390f35b3480156102c157600080fd5b506102dc60048036038101906102d79190611695565b6108db565b005b3480156102ea57600080fd5b5061030560048036038101906103009190611695565b610a78565b6040516103129190611707565b60405180910390f35b34801561032757600080fd5b50610330610ab6565b60405161033d91906116d1565b60405180910390f35b34801561035257600080fd5b5061036d60048036038101906103689190611695565b610adc565b005b34801561037b57600080fd5b50610384610c79565b60405161039191906115be565b60405180910390f35b3480156103a657600080fd5b506103af610d46565b6040516103bc91906115be565b60405180910390f35b3480156103d157600080fd5b506103da610d50565b6040516103e791906116d1565b60405180910390f35b600781565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610486576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161047d9061177f565b60405180910390fd5b6000600460ff1660035416146104d1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016104c8906117eb565b60405180910390fd5b816004819055507f748f1cf617bdc8ef4fcd1cb516dc05cedf269e8dcad82183846d57eeec4bba5e60045460405161050991906115be565b60405180910390a16004549050919050565b60035481565b6000806060600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161057091906116d1565b6040516020818303038152906040527fab73e316000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516105fa919061187c565b6000604051808303816000865af19150503d8060008114610637576040519150601f19603f3d011682016040523d82523d6000602084013e61063c565b606091505b50809250819350505081610685576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161067c906118df565b60405180910390fd5b8061068f9061193e565b6001900492505050919050565b60006106a782610d55565b6106b057600080fd5b8173ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f193505050501580156106f8573d6000803e3d6000fd5b50600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167f26162814817e23ec5035d6a2edc6c422da2da2119e27cfca6be65cc2dc55ca4c60045460405161075991906115be565b60405180910390a36004549050919050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600882106107d6576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107cd906119f1565b60405180910390fd5b600060035483161461081d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161081490611a5d565b60405180910390fd5b816003600082825417925050819055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff166040516108a5929190611a7d565b60405180910390a26003549050919050565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610969576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109609061177f565b60405180910390fd5b6000600160ff1660035416146109b4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ab906117eb565b60405180910390fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051610a6d929190611a7d565b60405180910390a250565b6000610a8382611099565b610a905760009050610ab1565b610a998261130d565b610aa65760009050610ab1565b610aae611581565b90505b919050565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610b6a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b619061177f565b60405180910390fd5b6000600260ff166003541614610bb5576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bac906117eb565b60405180910390fd5b80600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506003547f829c15f635123f612942c5f6ba4c6c203609473dc8b2398f38ccda8866f6ff7d600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16604051610c6e929190611a7d565b60405180910390a250565b6000610c8433610d55565b610c8d57600080fd5b3373ffffffffffffffffffffffffffffffffffffffff166108fc6004549081150290604051600060405180830381858888f19350505050158015610cd5573d6000803e3d6000fd5b50600073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167f26162814817e23ec5035d6a2edc6c422da2da2119e27cfca6be65cc2dc55ca4c600454604051610d3691906115be565b60405180910390a3600454905090565b6000600454905090565b600090565b6000806060610d62611581565b610da1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d9890611af2565b60405180910390fd5b610daa8461130d565b610de9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610de090611b5e565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1603610e4a57600192505050611094565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1684604051602401610e9491906116d1565b6040516020818303038152906040527fb1a997ac000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051610f1e919061187c565b6000604051808303816000865af19150503d8060008114610f5b576040519150601f19603f3d011682016040523d82523d6000602084013e610f60565b606091505b50809250819350505081610fa9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa090611bca565b60405180910390fd5b60007f01000000000000000000000000000000000000000000000000000000000000000281601f81518110610fe157610fe0611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff19160361108d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161108490611c65565b60405180910390fd5b6001925050505b919050565b6000806060600073ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036110ff57600192505050611308565b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168460405160240161114991906116d1565b6040516020818303038152906040527fc23697a8000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506040516111d3919061187c565b6000604051808303816000865af19150503d8060008114611210576040519150601f19603f3d011682016040523d82523d6000602084013e611215565b606091505b5080925081935050508161125e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161125590611bca565b60405180910390fd5b60017f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061129657611295611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b919050565b6000806060600073ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16036113735760019250505061157c565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16846040516024016113bd91906116d1565b6040516020818303038152906040527f3ef25013000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050604051611447919061187c565b6000604051808303816000865af19150503d8060008114611484576040519150601f19603f3d011682016040523d82523d6000602084013e611489565b606091505b508092508193505050816114d2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114c990611cd1565b60405180910390fd5b60017f01000000000000000000000000000000000000000000000000000000000000000281601f8151811061150a57611509611bea565b5b60200101517f010000000000000000000000000000000000000000000000000000000000000090047f0100000000000000000000000000000000000000000000000000000000000000027effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614925050505b919050565b60003073ffffffffffffffffffffffffffffffffffffffff16316004541115905090565b6000819050919050565b6115b8816115a5565b82525050565b60006020820190506115d360008301846115af565b92915050565b600080fd5b6115e7816115a5565b81146115f257600080fd5b50565b600081359050611604816115de565b92915050565b6000602082840312156116205761161f6115d9565b5b600061162e848285016115f5565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061166282611637565b9050919050565b61167281611657565b811461167d57600080fd5b50565b60008135905061168f81611669565b92915050565b6000602082840312156116ab576116aa6115d9565b5b60006116b984828501611680565b91505092915050565b6116cb81611657565b82525050565b60006020820190506116e660008301846116c2565b92915050565b60008115159050919050565b611701816116ec565b82525050565b600060208201905061171c60008301846116f8565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000611769600d83611722565b915061177482611733565b602082019050919050565b600060208201905081810360008301526117988161175c565b9050919050565b7f4552525f5345414c454400000000000000000000000000000000000000000000600082015250565b60006117d5600a83611722565b91506117e08261179f565b602082019050919050565b60006020820190508181036000830152611804816117c8565b9050919050565b600081519050919050565b600081905092915050565b60005b8381101561183f578082015181840152602081019050611824565b60008484015250505050565b60006118568261180b565b6118608185611816565b9350611870818560208601611821565b80840191505092915050565b6000611888828461184b565b915081905092915050565b7f4552525f504552494f445f4241434b454e445f4552524f520000000000000000600082015250565b60006118c9601883611722565b91506118d482611893565b602082019050919050565b600060208201905081810360008301526118f8816118bc565b9050919050565b6000819050602082019050919050565b6000819050919050565b6000611925825161190f565b80915050919050565b60008160020a8302905092915050565b60006119498261180b565b82611953846118ff565b905061195e81611919565b9250602082101561199e576119997fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8360200360080261192e565b831692505b5050919050565b7f4552525f494e56414c49445f5354415445000000000000000000000000000000600082015250565b60006119db601183611722565b91506119e6826119a5565b602082019050919050565b60006020820190508181036000830152611a0a816119ce565b9050919050565b7f4552525f414c52454144595f4c4f434b45440000000000000000000000000000600082015250565b6000611a47601283611722565b9150611a5282611a11565b602082019050919050565b60006020820190508181036000830152611a7681611a3a565b9050919050565b6000604082019050611a9260008301856116c2565b611a9f60208301846116c2565b9392505050565b7f4552525f494e53554646494349454e545f42414c414e43450000000000000000600082015250565b6000611adc601883611722565b9150611ae782611aa6565b602082019050919050565b60006020820190508181036000830152611b0b81611acf565b9050919050565b7f4552525f4e4f545f494e5f57484954454c495354000000000000000000000000600082015250565b6000611b48601483611722565b9150611b5382611b12565b602082019050919050565b60006020820190508181036000830152611b7781611b3b565b9050919050565b7f4552525f504552494f445f4241434b454e440000000000000000000000000000600082015250565b6000611bb4601283611722565b9150611bbf82611b7e565b602082019050919050565b60006020820190508181036000830152611be381611ba7565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4552525f504552494f445f434845434b00000000000000000000000000000000600082015250565b6000611c4f601083611722565b9150611c5a82611c19565b602082019050919050565b60006020820190508181036000830152611c7e81611c42565b9050919050565b7f4552525f52454749535452595f4241434b454e44000000000000000000000000600082015250565b6000611cbb601483611722565b9150611cc682611c85565b602082019050919050565b60006020820190508181036000830152611cea81611cae565b905091905056fea2646970667358221220e5ed9728ff96283e127fe7de460ec146dbbef33362f9a7cda3cd9d0cef13e81a64736f6c63430008120033 +\ No newline at end of file diff --git a/python/eth_faucet/data/EthFaucet.metadata.json b/python/eth_faucet/data/EthFaucet.metadata.json @@ -1 +1 @@ -{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"FaucetAmountChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Give","type":"event"},{"anonymous":false,"inputs":[],"name":"ImNotGassy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_sealState","type":"uint256"},{"indexed":false,"internalType":"address","name":"_registry","type":"address"},{"indexed":false,"internalType":"address","name":"_periodChecker","type":"address"}],"name":"SealStateChange","type":"event"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"check","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gimme","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"nextTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodChecker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"seal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_v","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_checker","type":"address"}],"name":"setPeriodChecker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"setRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"tokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"EthFaucet.sol":"EthFacuet"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"EthFaucet.sol":{"keccak256":"0x4eee39d6ae6437809f3dc9a38a6541224c66586a6e1735411946386af156efc5","license":"GPL-3.0-or-later","urls":["bzz-raw://ffb6836ece8743ce991344bb7cbfe615c5193cc8976e334bbc87c545a502a76c","dweb:/ipfs/QmcromwDBMiPDKJKRA4ygWDwF9t3MvE4BNdgmQMYcERX6R"]}},"version":1} +{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"FaucetAmountChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_recipient","type":"address"},{"indexed":true,"internalType":"address","name":"_token","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Give","type":"event"},{"anonymous":false,"inputs":[],"name":"ImNotGassy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"_sealState","type":"uint256"},{"indexed":false,"internalType":"address","name":"_registry","type":"address"},{"indexed":false,"internalType":"address","name":"_periodChecker","type":"address"}],"name":"SealStateChange","type":"event"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"check","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"gimme","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_recipient","type":"address"}],"name":"giveTo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxSealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_subject","type":"address"}],"name":"nextTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodChecker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"registry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_state","type":"uint256"}],"name":"seal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sealState","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_v","type":"uint256"}],"name":"setAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_checker","type":"address"}],"name":"setPeriodChecker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_registry","type":"address"}],"name":"setRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"tokenAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"EthFaucet.sol":"EthFacuet"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"EthFaucet.sol":{"keccak256":"0x914fa90608a36d5d6082a1bdba168c849a3ea34d70d3dd6e1fef143554840f19","license":"GPL-3.0-or-later","urls":["bzz-raw://b4efbed22465930f683933bd5b4f74a74d1f53c0c34a1231fbedcff92a3eeba2","dweb:/ipfs/QmT6szY5nAEs1megXscAsYkM9rke8M8VLj3MrQEP5hTekn"]}},"version":1} diff --git a/python/eth_faucet/data/PeriodSimple.bin b/python/eth_faucet/data/PeriodSimple.bin @@ -1 +1 @@ -608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610c48806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063ab73e3161161008e578063ab73e3161461016f578063b1a997ac1461019f578063c23697a8146101cf578063c3173774146101ff578063ef78d4fd1461021d578063f4430dd81461023b576100c6565b80630f3a9f65146100cb5780634b6bdf1d146100e75780634ee577b41461010557806387020d6b146101355780638da5cb5b14610151575b600080fd5b6100e560048036038101906100e0919061087d565b610257565b005b6100ef610326565b6040516100fc91906108eb565b60405180910390f35b61011f600480360381019061011a9190610932565b61034c565b60405161012c919061096e565b60405180910390f35b61014f600480360381019061014a919061087d565b610364565b005b6101596103fd565b60405161016691906108eb565b60405180910390f35b61018960048036038101906101849190610932565b610421565b604051610196919061096e565b60405180910390f35b6101b960048036038101906101b49190610932565b610477565b6040516101c691906109a4565b60405180910390f35b6101e960048036038101906101e49190610932565b610682565b6040516101f691906109a4565b60405180910390f35b61020761079a565b604051610214919061096e565b60405180910390f35b6102256107a0565b604051610232919061096e565b60405180910390f35b61025560048036038101906102509190610932565b6107a6565b005b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146102e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102dc90610a1c565b60405180910390fd5b806002819055507faf2decb129b74e79e086ab3d8c7bb0399bfba530c01e74fe4130ab9784e115578160405161031b919061096e565b60405180910390a150565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60046020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103bc57600080fd5b806003819055507f565196b96812774c1c5f73698d513cb6d8141ec4ecdbb428486d6ad64b4c81aa816040516103f2919061096e565b60405180910390a150565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104709190610a6b565b9050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806105215750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055790610aeb565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff1663c23697a8836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016105b591906108eb565b602060405180830381865afa1580156105d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f69190610b37565b610635576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161062c90610bb0565b60405180910390fd5b42600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555060019050919050565b60006003548273ffffffffffffffffffffffffffffffffffffffff163110156106aa57600080fd5b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036106fa5760019050610795565b3073ffffffffffffffffffffffffffffffffffffffff1663ab73e316836040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161074f91906108eb565b602060405180830381865afa15801561076c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107909190610be5565b421190505b919050565b60035481565b60025481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107fe57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080fd5b6000819050919050565b61085a81610847565b811461086557600080fd5b50565b60008135905061087781610851565b92915050565b60006020828403121561089357610892610842565b5b60006108a184828501610868565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108d5826108aa565b9050919050565b6108e5816108ca565b82525050565b600060208201905061090060008301846108dc565b92915050565b61090f816108ca565b811461091a57600080fd5b50565b60008135905061092c81610906565b92915050565b60006020828403121561094857610947610842565b5b60006109568482850161091d565b91505092915050565b61096881610847565b82525050565b6000602082019050610983600083018461095f565b92915050565b60008115159050919050565b61099e81610989565b82525050565b60006020820190506109b96000830184610995565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b6000610a06600d836109bf565b9150610a11826109d0565b602082019050919050565b60006020820190508181036000830152610a35816109f9565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a7682610847565b9150610a8183610847565b9250828201905080821115610a9957610a98610a3c565b5b92915050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b6000610ad5600a836109bf565b9150610ae082610a9f565b602082019050919050565b60006020820190508181036000830152610b0481610ac8565b9050919050565b610b1481610989565b8114610b1f57600080fd5b50565b600081519050610b3181610b0b565b92915050565b600060208284031215610b4d57610b4c610842565b5b6000610b5b84828501610b22565b91505092915050565b7f4552525f5052454d415455524500000000000000000000000000000000000000600082015250565b6000610b9a600d836109bf565b9150610ba582610b64565b602082019050919050565b60006020820190508181036000830152610bc981610b8d565b9050919050565b600081519050610bdf81610851565b92915050565b600060208284031215610bfb57610bfa610842565b5b6000610c0984828501610bd0565b9150509291505056fea2646970667358221220f1bca856487cc7834827fc8deb7e33a665fb08ecaee9bc82fe19b972a843c1d064736f6c63430008120033 -\ No newline at end of file +608060405234801561001057600080fd5b50336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550610bbd806100c16000396000f3fe608060405234801561001057600080fd5b50600436106100c6576000357c010000000000000000000000000000000000000000000000000000000090048063ab73e3161161008e578063ab73e3161461016f578063b1a997ac1461019f578063c23697a8146101cf578063c3173774146101ff578063ef78d4fd1461021d578063f4430dd81461023b576100c6565b80630f3a9f65146100cb5780634b6bdf1d146100e75780634ee577b41461010557806387020d6b146101355780638da5cb5b14610151575b600080fd5b6100e560048036038101906100e0919061085e565b610257565b005b6100ef610326565b6040516100fc91906108cc565b60405180910390f35b61011f600480360381019061011a9190610913565b61034c565b60405161012c919061094f565b60405180910390f35b61014f600480360381019061014a919061085e565b610364565b005b6101596103fd565b60405161016691906108cc565b60405180910390f35b61018960048036038101906101849190610913565b610421565b604051610196919061094f565b60405180910390f35b6101b960048036038101906101b49190610913565b610477565b6040516101c69190610985565b60405180910390f35b6101e960048036038101906101e49190610913565b610651565b6040516101f69190610985565b60405180910390f35b61020761077b565b604051610214919061094f565b60405180910390f35b610225610781565b604051610232919061094f565b60405180910390f35b61025560048036038101906102509190610913565b610787565b005b3373ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16146102e5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016102dc906109fd565b60405180910390fd5b806002819055507faf2decb129b74e79e086ab3d8c7bb0399bfba530c01e74fe4130ab9784e115578160405161031b919061094f565b60405180910390a150565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b60046020528060005260406000206000915090505481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146103bc57600080fd5b806003819055507f565196b96812774c1c5f73698d513cb6d8141ec4ecdbb428486d6ad64b4c81aa816040516103f2919061094f565b60405180910390a150565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000600254600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020546104709190610a4c565b9050919050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614806105215750600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16145b610560576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161055790610acc565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff1663c23697a8836040518263ffffffff167c01000000000000000000000000000000000000000000000000000000000281526004016105b591906108cc565b602060405180830381865afa1580156105d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105f69190610b18565b610603576000905061064c565b42600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550600190505b919050565b60008060035411801561067d57506003548273ffffffffffffffffffffffffffffffffffffffff163110155b1561068b5760009050610776565b6000600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054036106db5760019050610776565b3073ffffffffffffffffffffffffffffffffffffffff1663ab73e316836040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040161073091906108cc565b602060405180830381865afa15801561074d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107719190610b5a565b421190505b919050565b60035481565b60025481565b60008054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146107df57600080fd5b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b600080fd5b6000819050919050565b61083b81610828565b811461084657600080fd5b50565b60008135905061085881610832565b92915050565b60006020828403121561087457610873610823565b5b600061088284828501610849565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006108b68261088b565b9050919050565b6108c6816108ab565b82525050565b60006020820190506108e160008301846108bd565b92915050565b6108f0816108ab565b81146108fb57600080fd5b50565b60008135905061090d816108e7565b92915050565b60006020828403121561092957610928610823565b5b6000610937848285016108fe565b91505092915050565b61094981610828565b82525050565b60006020820190506109646000830184610940565b92915050565b60008115159050919050565b61097f8161096a565b82525050565b600060208201905061099a6000830184610976565b92915050565b600082825260208201905092915050565b7f4552525f4e4f545f4f574e455200000000000000000000000000000000000000600082015250565b60006109e7600d836109a0565b91506109f2826109b1565b602082019050919050565b60006020820190508181036000830152610a16816109da565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000610a5782610828565b9150610a6283610828565b9250828201905080821115610a7a57610a79610a1d565b5b92915050565b7f4552525f41434345535300000000000000000000000000000000000000000000600082015250565b6000610ab6600a836109a0565b9150610ac182610a80565b602082019050919050565b60006020820190508181036000830152610ae581610aa9565b9050919050565b610af58161096a565b8114610b0057600080fd5b50565b600081519050610b1281610aec565b92915050565b600060208284031215610b2e57610b2d610823565b5b6000610b3c84828501610b03565b91505092915050565b600081519050610b5481610832565b92915050565b600060208284031215610b7057610b6f610823565b5b6000610b7e84828501610b45565b9150509291505056fea2646970667358221220c9c559403f5d7b354fae12a3be7f60bbb86079120defa0241703f4ebce83b45664736f6c63430008120033 +\ No newline at end of file diff --git a/python/eth_faucet/data/PeriodSimple.metadata.json b/python/eth_faucet/data/PeriodSimple.metadata.json @@ -1 +1 @@ -{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"BalanceThresholdChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"PeriodChange","type":"event"},{"inputs":[],"name":"balanceThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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":[{"internalType":"address","name":"_subject","type":"address"}],"name":"next","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":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"setBalanceThreshold","outputs":[],"stateMutability":"nonpayable","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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"PeriodSimple.sol":"PeriodSimple"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"PeriodSimple.sol":{"keccak256":"0xaa53391796f933e59e3c6809d3a19e35623f78ca90f20386c14d3b4845df62d3","license":"GPL-3.0-or-later","urls":["bzz-raw://e8ab3b6c5568c7907c2e515e43c68da038629f5adcb576083a73ede9a4879661","dweb:/ipfs/QmUSY345fKi8Neq2pkKPGbyMYV9bmHALFtj3QviodprEQr"]}},"version":1} +{"compiler":{"version":"0.8.18+commit.87f61d96"},"language":"Solidity","output":{"abi":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"BalanceThresholdChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_value","type":"uint256"}],"name":"PeriodChange","type":"event"},{"inputs":[],"name":"balanceThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"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":[{"internalType":"address","name":"_subject","type":"address"}],"name":"next","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":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"poker","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"setBalanceThreshold","outputs":[],"stateMutability":"nonpayable","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"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"compilationTarget":{"PeriodSimple.sol":"PeriodSimple"},"evmVersion":"byzantium","libraries":{},"metadata":{"bytecodeHash":"ipfs"},"optimizer":{"enabled":false,"runs":200},"remappings":[]},"sources":{"PeriodSimple.sol":{"keccak256":"0x45faa9b0307c14cd87913aa6719092b693d47962285f659d1d01680ee9820527","license":"GPL-3.0-or-later","urls":["bzz-raw://29186cc92b9f6324e2043abe9ac74787866992c00ffeb0e3fc81d345d8c04ed1","dweb:/ipfs/QmXJaGaWBBFbdyQWaAicjXN6aC2w5Yvr97kXVVimHWAN7i"]}},"version":1} diff --git a/python/eth_faucet/unittest/__init__.py b/python/eth_faucet/unittest/__init__.py @@ -0,0 +1 @@ +from .base import * diff --git a/python/eth_faucet/unittest/base.py b/python/eth_faucet/unittest/base.py @@ -0,0 +1,190 @@ +# 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.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.tx import TxFactory +from chainlib.eth.contract import ABIContractType +from chainlib.eth.block import block_by_number +from eth_accounts_index.registry import AccountRegistry + +# local import +from eth_faucet import EthFaucet +from eth_faucet.period import PeriodSimple + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + +moddir = os.path.dirname(__file__) +datadir = os.path.join(moddir, '..', 'data') + + +class TestFaucetBase(EthTesterCase): + + def setUp(self): + super(TestFaucetBase, self).setUp() + self.conn = RPCConnection.connect(self.chain_spec, 'default') + 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.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)) + + +class TestFaucetRegistryBase(TestFaucetBase): + + def setUpRegistry(self): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash, o) = c.constructor(self.accounts[0]) + self.conn = RPCConnection.connect(self.chain_spec, 'default') + r = self.conn.do(o) + o = receipt(r) + r = self.conn.do(o) + self.registry_address = to_checksum_address(r['contract_address']) + + (tx_hash_hex, o) = c.add_writer(self.registry_address, self.accounts[0], self.accounts[0]) + self.conn.do(o) + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + (tx_hash_hex, o) = c.add(self.registry_address, self.accounts[0], self.accounts[1]) + self.conn.do(o) + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.set_registry(self.address, self.accounts[0], self.registry_address) + self.conn.do(o) + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + + def setUp(self): + super(TestFaucetRegistryBase, self).setUp() + self.setUpRegistry() + + +class TestFaucetPeriodBase(TestFaucetBase): + + def setUpPeriod(self): + self.conn = RPCConnection.connect(self.chain_spec, 'default') + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = PeriodSimple(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + (tx_hash_hex, o) = c.constructor(self.accounts[0]) + r = self.conn.do(o) + + 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_address = 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.set_period_checker(self.address, self.accounts[0], self.period_store_address) + 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_address, 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) + + self.period = 0 + self.threshold = 0 + + + def setUp(self): + super(TestFaucetPeriodBase, self).setUp() + self.setUpPeriod() + + + def set_period(self, period): + 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(period) + data = enc.get() + tx = c.template(self.accounts[0], self.period_store_address, 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) + self.period = period + + + def set_threshold(self, threshold): + nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) + c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + enc = ABIContractEncoder() + enc.method('setBalanceThreshold') + enc.typ(ABIContractType.UINT256) + enc.uint256(threshold) + data = enc.get() + tx = c.template(self.accounts[0], self.period_store_address, 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) + + self.threshold = threshold + + +class TestFaucetFullBase(TestFaucetRegistryBase, TestFaucetPeriodBase): + + def setUp(self): + super(TestFaucetFullBase, self).setUp() + self.setUpPeriod() diff --git a/python/setup.cfg b/python/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = eth-faucet -version = 0.3.1 +version = 0.3.2 description = Gas token gifter with controls from time intervals, amounts and access. author = Louis Holbrook author_email = dev@holbrook.no diff --git a/python/tests/test_basic.py b/python/tests/test_basic.py @@ -15,26 +15,13 @@ from chainlib.eth.gas import OverrideGasOracle # local import from eth_faucet import EthFaucet +from eth_faucet.unittest import TestFaucetBase logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() -class TestFaucet(EthTesterCase): - - def setUp(self): - super(TestFaucet, self).setUp() - self.conn = RPCConnection.connect(self.chain_spec, 'default') - 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.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)) - +class TestFaucet(TestFaucetBase): def test_basic(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) @@ -55,6 +42,10 @@ class TestFaucet(EthTesterCase): def test_basic_funding(self): + o = balance(self.accounts[2]) + r = self.conn.do(o) + prebalance = int(r, 16) + 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]) @@ -63,28 +54,18 @@ class TestFaucet(EthTesterCase): r = self.conn.do(o) self.assertEqual(r['status'], 1) - o = balance(self.accounts[9]) - r = self.conn.do(o) - prebalance = int(r, 16) - - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - o = balance(self.accounts[2]) r = self.conn.do(o) self.assertEqual(int(r, 16), prebalance) (tx_hash, o) = c.set_amount(self.address, self.accounts[0], 1000) r = self.conn.do(o) - o = receipt(tx_hash_hex) r = self.conn.do(o) self.assertEqual(r['status'], 1) (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) @@ -146,6 +127,7 @@ class TestFaucet(EthTesterCase): r = self.conn.do(o) self.assertEqual(int(r, 16), prebalance - cost + 1000) + def test_payable_with_tx_data(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) @@ -169,5 +151,7 @@ class TestFaucet(EthTesterCase): r = self.conn.do(o) self.assertEqual(int(r, 16), prebalance - cost) + + if __name__ == '__main__': unittest.main() diff --git a/python/tests/test_check.py b/python/tests/test_check.py @@ -0,0 +1,82 @@ +# 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.address import to_checksum_address +from chainlib.eth.gas import balance +from chainlib.eth.gas import Gas +from chainlib.eth.gas import OverrideGasOracle + +# local import +from eth_faucet import EthFaucet +from eth_faucet.unittest import TestFaucetFullBase + +logging.basicConfig(level=logging.DEBUG) +logg = logging.getLogger() + + +class TestFaucet(TestFaucetFullBase): + + def test_check_registry(self): + c = EthFaucet(self.chain_spec) + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + o = c.check(self.address, self.accounts[2], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 0) + + + def test_check_period_time(self): + self.set_period(100) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.conn) + c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) + + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + (tx_hash_hex, o) = c.gimme(self.address, self.accounts[1]) + self.conn.do(o) + o = receipt(tx_hash_hex) + r = self.conn.do(o) + self.assertEqual(r['status'], 1) + + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 0) + + + def test_check_period_balance(self): + o = balance(self.accounts[1]) + r = self.conn.do(o) + prebalance = int(r, 16) + + c = EthFaucet(self.chain_spec) + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + self.set_threshold(prebalance + 1) + + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 1) + + self.set_threshold(prebalance) + + o = c.check(self.address, self.accounts[1], sender_address=self.accounts[0]) + r = self.conn.do(o) + self.assertEqual(int(r, 16), 0) + + +if __name__ == '__main__': + unittest.main() diff --git a/python/tests/test_period.py b/python/tests/test_period.py @@ -20,82 +20,16 @@ from chainlib.eth.block import block_by_number # local imports from eth_faucet import EthFaucet from eth_faucet.period import PeriodSimple +from eth_faucet.unittest import TestFaucetPeriodBase logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() - - moddir = os.path.dirname(__file__) datadir = os.path.join(moddir, '..', 'eth_faucet', 'data') -class TestFaucetPeriod(EthTesterCase): - - def setUp(self): - super(TestFaucetPeriod, self).setUp() - # DRY - self.conn = RPCConnection.connect(self.chain_spec, 'default') - nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) - c = PeriodSimple(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.constructor(self.accounts[0]) - r = self.conn.do(o) - - 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_address = 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_address) - 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_address, 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) - +class TestFaucetPeriod(TestFaucetPeriodBase): def test_period_basic(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) @@ -155,51 +89,23 @@ class TestFaucetPeriod(EthTesterCase): def test_balance(self): - o = balance(self.accounts[2]) + o = balance(self.accounts[1]) r = self.conn.do(o) prebalance = int(r, 16) - nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) - c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - enc = ABIContractEncoder() - enc.method('setBalanceThreshold') - enc.typ(ABIContractType.UINT256) - enc.uint256(prebalance + 1) - data = enc.get() - tx = c.template(self.accounts[0], self.period_store_address, 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[2], self.conn) + self.set_threshold(prebalance / 2) + + nonce_oracle = RPCNonceOracle(self.accounts[1], self.conn) c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.gimme(self.address, self.accounts[2]) + (tx_hash_hex, o) = c.gimme(self.address, self.accounts[1]) self.conn.do(o) o = receipt(tx_hash_hex) r = self.conn.do(o) self.assertEqual(r['status'], 0) - nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) - c = TxFactory(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - enc = ABIContractEncoder() - enc.method('setBalanceThreshold') - enc.typ(ABIContractType.UINT256) - enc.uint256(1) - data = enc.get() - tx = c.template(self.accounts[0], self.period_store_address, 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) + self.set_threshold(prebalance) - nonce_oracle = RPCNonceOracle(self.accounts[2], self.conn) - c = EthFaucet(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash_hex, o) = c.gimme(self.address, self.accounts[2]) + (tx_hash_hex, o) = c.gimme(self.address, self.accounts[1]) self.conn.do(o) o = receipt(tx_hash_hex) r = self.conn.do(o) diff --git a/python/tests/test_registry.py b/python/tests/test_registry.py @@ -20,55 +20,13 @@ from eth_accounts_index.registry import AccountRegistry # local imports from eth_faucet import EthFaucet +from eth_faucet.unittest import TestFaucetRegistryBase logging.basicConfig(level=logging.DEBUG) logg = logging.getLogger() -class TestFaucetRegistry(EthTesterCase): - - def setUp(self): - super(TestFaucetRegistry, self).setUp() - # DRY - self.conn = RPCConnection.connect(self.chain_spec, 'default') - nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) - - c = AccountRegistry(self.chain_spec, signer=self.signer, nonce_oracle=nonce_oracle) - (tx_hash, o) = c.constructor(self.accounts[0]) - self.conn = RPCConnection.connect(self.chain_spec, 'default') - r = self.conn.do(o) - - o = receipt(r) - r = self.conn.do(o) - self.registry_address = to_checksum_address(r['contract_address']) - - (tx_hash_hex, o) = c.add_writer(self.registry_address, self.accounts[0], self.accounts[0]) - self.conn.do(o) - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - (tx_hash_hex, o) = c.add(self.registry_address, self.accounts[0], self.accounts[1]) - self.conn.do(o) - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - - 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_registry(self.address, self.accounts[0], self.registry_address) - self.conn.do(o) - o = receipt(tx_hash_hex) - r = self.conn.do(o) - self.assertEqual(r['status'], 1) - +class TestFaucetRegistry(TestFaucetRegistryBase): def test_basic(self): nonce_oracle = RPCNonceOracle(self.accounts[0], self.conn) diff --git a/solidity/EthFaucet.sol b/solidity/EthFaucet.sol @@ -85,7 +85,7 @@ contract EthFacuet { } function checkBalance() private view returns(bool) { - return amount >= address(this).balance; + return amount <= address(this).balance; } function check(address _recipient) public returns(bool) { diff --git a/solidity/PeriodSimple.sol b/solidity/PeriodSimple.sol @@ -39,7 +39,9 @@ contract PeriodSimple { } function check(address _subject) external view returns(bool) { - require(_subject.balance >= balanceThreshold); + if (balanceThreshold > 0 && _subject.balance >= balanceThreshold) { + return false; + } if (lastUsed[_subject] == 0) { return true; } @@ -48,7 +50,9 @@ contract PeriodSimple { function poke(address _subject) external returns(bool) { require(msg.sender == owner || msg.sender == poker, 'ERR_ACCESS'); - require(this.check(_subject), 'ERR_PREMATURE'); + if (!this.check(_subject)) { + return false; + } lastUsed[_subject] = block.timestamp; return true; }