git-consensus / contracts

Converts the informal ownership structure of an open-source git project to a formal DAO, with token distribution mechanisms for contributors.
GNU General Public License v3.0
13 stars 0 forks source link

added maxMintablePerHash to createToken() and IToken errors #9

Closed mattstam closed 2 years ago

mattstam commented 2 years ago

Description

Add new maxMintablePerHash to createToken(), which will be the maximum that can be minted at once. This will set a hard cap on a single hash[i]->value[i] during GitConsensus.addRelease().

Also gives frontend something to use as a reasonable max to read for how much they can assign to a commit during the pre-proposal process.

Test Coverage

Unit tests:

Running 10 tests for contracts/test/Utils.t.sol:UtilsTest
[PASS] testOK_parseAddrGeneralCase() (gas: 23336)
[PASS] testOk_indexOfAddrNonexistentADDR_STRNonemptyMsg() (gas: 6515)
[PASS] testOk_indexOfAddressGeneralCase() (gas: 10596)
[PASS] testOk_indexOfAddressNonexistentADDR_STREmptyMsg() (gas: 257)
[PASS] testOk_indexOfAddressTrivialCase() (gas: 10303)
[PASS] testOk_substringEmptyString() (gas: 1168)
[PASS] testOk_substringEntireString() (gas: 11962)
[PASS] testOk_substringGeneralCase() (gas: 25086)
[PASS] testOk_substringOutOfBoundsNoOverflow() (gas: 7320)
[PASS] testOk_substringOutOfBoundsOverflow() (gas: 6263)
Test result: ok. 10 passed; 0 failed; finished in 1.00ms

Running 1 test for contracts/test/GovernorFactory.t.sol:GasBenchmark
[PASS] testGas_createGovernor() (gas: 300691)
Test result: ok. 1 passed; 0 failed; finished in 806.00µs

Running 2 tests for contracts/test/TokenFactory.t.sol:GasBenchmark
[PASS] testGas_createTokenRandom() (gas: 448540)
[PASS] testGas_createTokenStatic() (gas: 591135)
Test result: ok. 2 passed; 0 failed; finished in 1.47ms

Running 2 tests for contracts/test/GitConsensus.t.sol:GasBenchmark
[PASS] testGas_commit() (gas: 434115)
[PASS] testGas_release() (gas: 444780)
Test result: ok. 2 passed; 0 failed; finished in 7.41ms

Running 2 tests for contracts/test/GovernorFactory.t.sol:WhenCreatingNewGovernor
[PASS] testOk_createGovernor(address,address,string,uint256,uint256,uint256,uint256,bytes32) (runs: 256, μ: 336871, ~: 346156)
[PASS] testOk_predictGovernorAddress(bytes32) (runs: 256, μ: 5731, ~: 5731)
Test result: ok. 2 passed; 0 failed; finished in 165.78ms

Running 6 tests for contracts/test/TokenFactory.t.sol:WhenCreatingNewToken
[PASS] testOk_createTokenDeterministicRandomDistribution(address,address,address,string,string,uint256,uint256,uint256,bytes32,bytes32) (runs: 256, μ: 556876, ~: 505256)
[PASS] testOk_createTokenDeterministicStaticDistribution(address,address,address,string,string,uint256,uint256,uint256,bytes32) (runs: 256, μ: 4900133, ~: 2768391)
[PASS] testOk_createTokenEmptyDistribution(address,address,address,string,string,uint256,bytes32) (runs: 256, μ: 323438, ~: 318711)
[PASS] testOk_createTokenRandomDistribution(address,address,address,string,string,uint256,uint256,uint256,bytes32,bytes32) (runs: 256, μ: 563570, ~: 516793)
[PASS] testOk_createTokenStaticDistribution(address,address,address,string,string,uint256,uint256,uint256,bytes32) (runs: 256, μ: 4652713, ~: 2037134)
[PASS] testOk_predictTokenAddress(bytes32) (runs: 256, μ: 5738, ~: 5738)
Test result: ok. 6 passed; 0 failed; finished in 7.08s

Running 20 tests for contracts/test/GitConsensus.t.sol:WhenCallingGitConsensus
[PASS] testOk_commitEmptyFailed(address) (runs: 256, μ: 61523, ~: 61523)
[PASS] testOk_commitEmptyMsgAddr(address) (runs: 256, μ: 349497, ~: 345957)
[PASS] testOk_commitEmptyMsgAddrMalformed(address) (runs: 256, μ: 93836, ~: 93836)
[PASS] testOk_commitFilledFailed(address) (runs: 256, μ: 952625, ~: 952625)
[PASS] testOk_commitFilledMsgAddr(address) (runs: 256, μ: 2137478, ~: 2133913)
[PASS] testOk_commitPartialFailed(address) (runs: 256, μ: 51926, ~: 51926)
[PASS] testOk_commitPartialMsgAddr(address) (runs: 256, μ: 336820, ~: 333407)
[PASS] testOk_commitTwoHashDiffMsgAddrNotMatch(address,address) (runs: 256, μ: 653831, ~: 647148)
[PASS] testOk_commitTwoHashDiffMsgAddrNotMatchWSender(address,address) (runs: 256, μ: 655617, ~: 648508)
[PASS] testOk_commitTwoHashDiffMsgStrNotMatch(address) (runs: 256, μ: 652268, ~: 645774)
[PASS] testOk_releaseDistributionSizeDiffFails(bytes32,bytes32,bytes20) (runs: 256, μ: 1055476, ~: 1055476)
[PASS] testOk_releaseEmptyFailed(bytes32,bytes32) (runs: 256, μ: 1012299, ~: 1012299)
[PASS] testOk_releaseEmptyMsgAddr(bytes32,bytes32) (runs: 256, μ: 1296295, ~: 1296243)
[PASS] testOk_releaseFilledFailed(bytes32,bytes32) (runs: 256, μ: 1838268, ~: 1838268)
[PASS] testOk_releaseFilledMsgAddr(bytes32,bytes32) (runs: 256, μ: 2890747, ~: 2890773)
[PASS] testOk_releasePartialFailed(bytes32,bytes32) (runs: 256, μ: 1002216, ~: 1002216)
[PASS] testOk_releasePartialMsgAddr(bytes32,bytes32) (runs: 256, μ: 1282717, ~: 1282694)
[PASS] testOk_releaseRandomDistribution(bytes32,bytes32,uint256,uint256,bytes32) (runs: 256, μ: 1487567, ~: 1378353)
[PASS] testOk_releaseStaticDistribution(bytes32,bytes32,uint256,uint256) (runs: 256, μ: 20845144, ~: 11601211)
[PASS] testOk_releaseTwoHashDiffMsgStrNotMatch(bytes32,bytes32) (runs: 256, μ: 1598620, ~: 1598500)

Integration tests:

 Git Consensus integration tests
    commits
      ✓ should succeed single commit that have address
      ✓ should succeed single commit that have address no space
      - should fail all commit that have partial address
      ✓ [loop] should succeed all example commit that have address
      ✓ [loop] should fail all example commit that have no address
    releases
      ✓ should fail release with different size hash and value arrays
      ✓ [loop] should fail all example tag that have no address
      ✓ should fail invalid release from non-governor
      ✓ should succeed valid release, commits from last tag to current
      ✓ should succeed valid release, commits from any
    clones
      ✓ should create clones using arguments