Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Name Service #78

Merged
merged 3 commits into from
Aug 5, 2024
Merged

Name Service #78

merged 3 commits into from
Aug 5, 2024

Conversation

mvandeberg
Copy link
Member

@mvandeberg mvandeberg commented Aug 2, 2024

Brief description

Bumps mock-vm to 1.2.0, re-adds sdk-as-cli, and adds helper functions for setting name service related values for testing.

Checklist

  • I have built this pull request locally
  • I have ran the unit tests locally
  • I have manually tested this pull request
  • I have reviewed my pull request
  • I have added any relevant tests

Demonstration

❯ yarn test         
yarn run v1.22.22
$ asp --verbose
       ___   _____                       __    
      /   | / ___/      ____  ___  _____/ /_   
     / /| | \__ \______/ __ \/ _ \/ ___/ __/   
    / ___ |___/ /_____/ /_/ /  __/ /__/ /_     
   /_/  |_/____/     / .___/\___/\___/\__/     
                    /_/                        

⚡AS-pect⚡ Test suite runner [8.0.1]
Using config: /home/michael/dev/koinos-sdk-as/as-pect.config.js
ASC Version: 0.27.1
[Log]Using code coverage: assembly/*.ts, assembly/util/*.ts
[Log]Using coverage: assembly/*.ts, assembly/util/*.ts
compiler mismatch: std/portable included twice
[Describe]: MockVM

 [Success]: ✔ should get the chain id
 [Success]: ✔ should set the contract arguments
 [Success]: ✔ should set the contract id
 [Success]: ✔ should set the head info
 [Success]: ✔ should set the last irreversible block
 [Success]: ✔ should set the caller
 [Success]: ✔ should set the transaction
 [Success]: ✔ should set the operation
 [Success]: ✔ should set the block
 [Success]: ✔ should set the authorities
 [Success]: ✔ should set the call contract results
 [Success]: ✔ should reset the MockVM database
 [Success]: ✔ should handle transactions
[Log] log 1
[Log] log 2
[Log] log 3
 [Success]: ✔ should handle logs
 [Success]: ✔ should handle error messages
 [Success]: ✔ should set verify vrf proof results
 [Success]: ✔ should set system authority
 [Success]: ✔ should reset cache
 [Success]: ✔ should set contract address

    [File]: __tests__/mockVM.spec.ts
  [Groups]: 2 pass, 2 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 19 pass,  0 fail, 19 total
    [Time]: 49.998ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Describe]: tryAdd

 [Success]: ✔ adds correctly
 [Success]: ✔ adds correctly - u128
 [Success]: ✔ reverts on addition overflow
 [Success]: ✔ reverts on addition overflow - u128
 [Success]: ✔ adds correctly if it does not overflow and the result is positive
 [Success]: ✔ adds correctly if it does not overflow and the result is negative
 [Success]: ✔ reverts on positive addition overflow
 [Success]: ✔ reverts on negative addition overflow

[Describe]: add

 [Success]: ✔ adds correctly
 [Success]: ✔ adds correctly - u128
[Contract Exit] could not add 18446744073709551615 to 1
[Contract Exit] could not add 1 to 18446744073709551615
 [Success]: ✔ reverts on addition overflow
[Contract Exit] could not add
[Contract Exit] could not add
 [Success]: ✔ reverts on addition overflow - u128
 [Success]: ✔ adds correctly if it does not overflow and the result is positive
 [Success]: ✔ adds correctly if it does not overflow and the result is negative
[Contract Exit] could not add 9223372036854775807 to 1
[Contract Exit] could not add 1 to 9223372036854775807
 [Success]: ✔ reverts on positive addition overflow
[Contract Exit] could not add -9223372036854775808 to -1
[Contract Exit] could not add -1 to -9223372036854775808
 [Success]: ✔ reverts on negative addition overflow
[Contract Exit] my message
[Contract Exit] my message1
[Contract Exit] my message2
 [Success]: ✔ reverts with a custom message

[Describe]: trySub

 [Success]: ✔ subtracts correctly
 [Success]: ✔ subtracts correctly - u128
 [Success]: ✔ reverts if subtraction result would be negative
 [Success]: ✔ reverts if subtraction result would be negative - u128
 [Success]: ✔ subtracts correctly if it does not overflow and the result is positive
 [Success]: ✔ subtracts correctly if it does not overflow and the result is negative
 [Success]: ✔ reverts on positive subtraction overflow
 [Success]: ✔ reverts on negative subtraction overflow

[Describe]: sub

 [Success]: ✔ subtracts correctly
 [Success]: ✔ subtracts correctly - u128
[Contract Exit] could not subtract 5678 from 1234
 [Success]: ✔ reverts if subtraction result would be negative
[Contract Exit] could not subtract
 [Success]: ✔ reverts if subtraction result would be negative - u128
 [Success]: ✔ subtracts correctly if it does not overflow and the result is positive
 [Success]: ✔ subtracts correctly if it does not overflow and the result is negative
[Contract Exit] could not subtract -1 from 9223372036854775807
 [Success]: ✔ reverts on positive subtraction overflow
[Contract Exit] could not subtract 1 from -9223372036854775808
 [Success]: ✔ reverts on negative subtraction overflow
[Contract Exit] my message
[Contract Exit] my message1
 [Success]: ✔ reverts with a custom message

[Describe]: tryMul

 [Success]: ✔ multiplies correctly
 [Success]: ✔ multiplies correctly - u128
 [Success]: ✔ multiplies correctly - signed integers
 [Success]: ✔ multiplies by zero correctly
 [Success]: ✔ multiplies by zero correctly - u128
 [Success]: ✔ multiplies by zero correctly - signed integers
 [Success]: ✔ reverts on multiplication overflow
 [Success]: ✔ reverts on multiplication overflow - u128
 [Success]: ✔ reverts on multiplication overflow, positive operands
 [Success]: ✔ reverts when minimum integer is multiplied by -1 - i64
 [Success]: ✔ reverts when minimum integer is multiplied by -1 - i32
 [Success]: ✔ reverts when minimum integer is multiplied by -1 - i16
 [Success]: ✔ reverts when minimum integer is multiplied by -1 - i8

[Describe]: mul

 [Success]: ✔ multiplies correctly
 [Success]: ✔ multiplies correctly - u128
 [Success]: ✔ multiplies by zero correctly
 [Success]: ✔ multiplies by zero correctly - u128
[Contract Exit] could not multiply
[Contract Exit] could not multiply
 [Success]: ✔ reverts on multiplication overflow - u128
[Contract Exit] could not multiply 9223372036854775807 by 2
[Contract Exit] could not multiply 2 by 9223372036854775807
 [Success]: ✔ reverts on multiplication overflow
[Contract Exit] my message
[Contract Exit] my message1
 [Success]: ✔ reverts on multiplication overflow with a custom message

[Describe]: tryDiv

 [Success]: ✔ divides correctly
 [Success]: ✔ divides correctly - u128
 [Success]: ✔ divides correctly - signed integers
 [Success]: ✔ divides zero correctly
 [Success]: ✔ divides zero correctly - u128
 [Success]: ✔ divides zero correctly - signed integers
 [Success]: ✔ returns complete number result on non-even division
 [Success]: ✔ returns complete number result on non-even division - u128
 [Success]: ✔ returns complete number result on non-even division - signed integers
 [Success]: ✔ reverts on division by zero
 [Success]: ✔ reverts on division by zero - u128
 [Success]: ✔ reverts on division by zero - signed integers
 [Success]: ✔ reverts on overflow, negative second - i64
 [Success]: ✔ reverts on overflow, negative second - i32
 [Success]: ✔ reverts on overflow, negative second - i16
 [Success]: ✔ reverts on overflow, negative second - i8

[Describe]: div

 [Success]: ✔ divides correctly
 [Success]: ✔ divides correctly - u128
 [Success]: ✔ divides zero correctly
 [Success]: ✔ divides zero correctly - u128
 [Success]: ✔ returns complete number result on non-even division
 [Success]: ✔ returns complete number result on non-even division - u128
[Contract Exit] could not divide 5678 by 0
 [Success]: ✔ reverts on division by zero
[Contract Exit] could not divide
 [Success]: ✔ reverts on division by zero - u128
[Contract Exit] my message
[Contract Exit] my message1
 [Success]: ✔ reverts on division by zero with a custom message

[Describe]: trymod

[Describe]: modulos correctly

 [Success]: ✔ when the dividend is smaller than the divisor
 [Success]: ✔ when the dividend is smaller than the divisor - u128
 [Success]: ✔ when the dividend is smaller than the divisor - signed integers
 [Success]: ✔ when the dividend is equal to the divisor
 [Success]: ✔ when the dividend is equal to the divisor - u128
 [Success]: ✔ when the dividend is equal to the divisor - signed integers
 [Success]: ✔ when the dividend is larger than the divisor
 [Success]: ✔ when the dividend is larger than the divisor - u128
 [Success]: ✔ when the dividend is larger than the divisor - signed integers
 [Success]: ✔ when the dividend is a multiple of the divisor
 [Success]: ✔ when the dividend is a multiple of the divisor - u128
 [Success]: ✔ when the dividend is a multiple of the divisor - signed integers

 [Success]: ✔ reverts with a 0 divisor
 [Success]: ✔ reverts with a 0 divisor - u128
 [Success]: ✔ reverts with a 0 divisor - signed integers
 [Success]: ✔ reverts on overflow, negative second - i64
 [Success]: ✔ reverts on overflow, negative second - i32
 [Success]: ✔ reverts on overflow, negative second - i16
 [Success]: ✔ reverts on overflow, negative second - i8

[Describe]: mod

[Describe]: modulos correctly

 [Success]: ✔ when the dividend is smaller than the divisor
 [Success]: ✔ when the dividend is smaller than the divisor - u128
 [Success]: ✔ when the dividend is equal to the divisor
 [Success]: ✔ when the dividend is equal to the divisor - u128
 [Success]: ✔ when the dividend is larger than the divisor
 [Success]: ✔ when the dividend is larger than the divisor - u128
 [Success]: ✔ when the dividend is a multiple of the divisor
 [Success]: ✔ when the dividend is a multiple of the divisor - u128

[Contract Exit] could not calulate 5678 modulo 0
 [Success]: ✔ reverts with a 0 divisor
[Contract Exit] could not calulate modulo
 [Success]: ✔ reverts with a 0 divisor - u128
[Contract Exit] my message
 [Success]: ✔ reverts with a 0 divisor with a custom message
[Contract Exit] my message
 [Success]: ✔ reverts with a 0 divisor with a custom message - u128

    [File]: __tests__/safeMath.spec.ts
  [Groups]: 14 pass, 14 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 110 pass,  0 fail, 110 total
    [Time]: 54.892ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Describe]: storage

 [Success]: ✔ should put and get an object in a Map
 [Success]: ✔ should get an object in a Map with default value
 [Success]: ✔ should check if storage has an object or not
 [Success]: ✔ should remove an object
 [Success]: ✔ should get next and prev object
 [Success]: ✔ should get many

[Describe]: storage with proto key

 [Success]: ✔ should put and get an object
 [Success]: ✔ should check if storage has an object or not
 [Success]: ✔ should remove an object
 [Success]: ✔ should get next and prev object
 [Success]: ✔ should get many
 [Success]: ✔ should put, get and remove an object in a Obj
 [Success]: ✔ should get  an object in a Obj with default value

    [File]: __tests__/storage.spec.ts
  [Groups]: 3 pass, 3 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 13 pass,  0 fail, 13 total
    [Time]: 25.691ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Describe]: SystemCalls

 [Success]: ✔ should get the chain id
 [Success]: ✔ should get the head info
 [Success]: ✔ should get the transaction
 [Success]: ✔ should get the transaction field
 [Success]: ✔ should get the operation
 [Success]: ✔ should get the block
 [Success]: ✔ should get the block field
 [Success]: ✔ should get the last irreversible block
[Error] Error: entry_point is not set
[Contract Exit] account '1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe' authorization failed
[Contract Exit] account '1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe' authorization failed
 [Success]: ✔ should require authorities
[Log] Hello World!
 [Success]: ✔ should log
[Event] Hello World! / [ '1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe' ] / SGVsbG8gV29ybGQh
[Log] 1DQzuCcTKacbs9GGScRTU1Hc8BsyARTPqe
 [Success]: ✔ should emit an event
[Contract Exit] unknown hash code
 [Success]: ✔ should hash
[Contract Exit] unexpected dsa
 [Success]: ✔ should recover a public key
 [Success]: ✔ should verify a signature
 [Success]: ✔ should should call a contract
 [Success]: ✔ should get the contract arguments
 [Success]: ✔ should get the contract id
 [Success]: ✔ should get the head info
 [Success]: ✔ should get the caller
[Contract Exit] 
[Contract Exit] my message A
[Contract Exit] my message B
[Contract Exit] my message C
 [Success]: ✔ should exit a contract
 [Success]: ✔ should put and get bytes
 [Success]: ✔ should put and get objects
 [Success]: ✔ should check authority using contract metadata

    [File]: __tests__/systemCalls.spec.ts
  [Groups]: 2 pass, 2 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 23 pass,  0 fail, 23 total
    [Time]: 53.838ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Describe]: token

 [Success]: ✔ should get the name of a token
 [Success]: ✔ should get the symbol of a token
 [Success]: ✔ should get the decimals of a token
 [Success]: ✔ should get the total supply of a token
 [Success]: ✔ should get the balance of an account
 [Success]: ✔ should transfer a token
 [Success]: ✔ should/not mint a token
 [Success]: ✔ should burn a token

    [File]: __tests__/token.spec.ts
  [Groups]: 2 pass, 2 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 8 pass,  0 fail, 8 total
    [Time]: 10.366ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[Describe]: Base58

 [Success]: ✔ should decode a Base58 string into a Uint8Array
 [Success]: ✔ should encode a Uint8Array into a Base58 string

[Describe]: Base64

 [Success]: ✔ should decode a Base64 string into a Uint8Array
 [Success]: ✔ should encode a Uint8Array into a Base64 string

[Describe]: StringBytes

 [Success]: ✔ should convert a string into a Uint8Array
 [Success]: ✔ should convert a Uint8Array into a string

[Describe]: Crypto

 [Success]: ✔ should convert a public key into an address
 [Success]: ✔ Multihash class

[Describe]: Arrays

 [Success]: ✔ should compare two Uint8Array
 [Success]: ✔ should convert hex strings

    [File]: __tests__/util.spec.ts
  [Groups]: 6 pass, 6 total
  [Result]: ✔ PASS
[Snapshot]: 0 total, 0 added, 0 removed, 0 different
 [Summary]: 10 pass,  0 fail, 10 total
    [Time]: 18.32ms

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Coverage Report:

┌──────────────────────────────┬───────┬───────┬───────┬───────┬─────────────────────────────────────────┐
│ File                         │ Total │ Block │ Func  │ Expr  │ Uncovered                               │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/systemCalls.ts      │ 68.6% │ 66%   │ 68.9% │ 82.4% │ 18:5, 22:9, 27:56, 27:3, 32:46, 32:3... │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/base64.ts      │ 100%  │ 100%  │ 100%  │ 100%  │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/base58.ts      │ 94.7% │ 91.7% │ 100%  │ 100%  │ 68:40                                   │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/stringBytes.ts │ 100%  │ 100%  │ 100%  │ N/A   │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/crypto.ts      │ 100%  │ 100%  │ 100%  │ N/A   │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/arrays.ts      │ 100%  │ 100%  │ 100%  │ 100%  │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/safeMath.ts    │ 99.2% │ 100%  │ 100%  │ 98.1% │ 262:35                                  │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/mockVM.ts      │ 96.5% │ 96.9% │ 96%   │ N/A   │ 347:58, 347:3                           │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/token.ts       │ 100%  │ 100%  │ 100%  │ N/A   │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ assembly/util/storage.ts     │ 100%  │ 100%  │ 100%  │ 100%  │                                         │
├──────────────────────────────┼───────┼───────┼───────┼───────┼─────────────────────────────────────────┤
│ total                        │ 89.1% │ 87.8% │ 86.8% │ 96.1% │                                         │
└──────────────────────────────┴───────┴───────┴───────┴───────┴─────────────────────────────────────────┘

  [Summary]
    [Tests]: 183 / 183
   [Groups]: 29 / 29
[Snapshots]: 0 / 0, Added 0, Changed 0
   [Result]: ✔ Pass!

Done in 2.17s.

@mvandeberg mvandeberg requested a review from sgerbino August 2, 2024 15:49
@mvandeberg mvandeberg marked this pull request as ready for review August 2, 2024 15:49
@sgerbino sgerbino merged commit d9ced48 into master Aug 5, 2024
6 checks passed
@sgerbino sgerbino deleted the nameservice branch August 5, 2024 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants