koinos / koinos-sdk-as

AssemblyScript (AS) Software Development Toolkit (SDK) for the Koinos Blockchain
https://roaminroe.github.io/koinos-as-sdk/
MIT License
5 stars 3 forks source link

use `System.getBytes` in `has` function #63

Closed roaminro closed 1 year ago

roaminro commented 1 year ago

Brief description

The has functions in Storage.Map and Storage.ProtoMap were relying on their internal get functions which would always return an object if a defaultValue was set in when instantiating those classes. Using System.getBytes directly prevents this issue from happening.

Checklist

Demonstration

[Describe]: storage

 [Success]: ✔ should put and get an object in a Map RTrace: +44
 [Success]: ✔ should get an object in a Map with default value RTrace: +18
 [Success]: ✔ should check if storage has an object or not RTrace: +36
 [Success]: ✔ should remove an object RTrace: +44
 [Success]: ✔ should get next and prev object RTrace: +121
 [Success]: ✔ should get many RTrace: +638

[Describe]: storage with proto key

 [Success]: ✔ should put and get an object RTrace: +41
 [Success]: ✔ should check if storage has an object or not RTrace: +37
 [Success]: ✔ should remove an object RTrace: +43
 [Success]: ✔ should get next and prev object RTrace: +122
 [Success]: ✔ should get many RTrace: +446
 [Success]: ✔ should put, get and remove an object in a Obj RTrace: +52
 [Success]: ✔ should get  an object in a Obj with default value RTrace: +23

    [File]: /home/rr/Documents/blockchain/koinos-sdk-as/__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]: 154.393ms