neo-project / neo-devpack-dotnet

NEO Development Pack
MIT License
79 stars 100 forks source link

[Neo Devpack Tests] add gas consume to the test #1076

Closed Jim8y closed 1 month ago

Jim8y commented 1 month ago

This pr adds gas consumption to the tests, by having gas cost, we can see which syntax consumes how many datoshis, and can further help us learn and optimize the compiler.

Jim8y commented 1 month ago

@shargon why every test consumes 10_0xxx_xxxx? Do you know which operation costs that 10_0000_0000, method call?

shargon commented 1 month ago

I have in mind a different approach for this with an Attribute like [GasCost(xxx)]. Let me check it...

Jim8y commented 1 month ago

@shargon some tests contain multiple contract calls, attribute may work for some tests, its not be conflict with this one.

shargon commented 1 month ago

It must be the native contract initialization, use CreateGasWatcher instead

Jim8y commented 1 month ago

It must be the native contract initialization, use CreateGasWatcher instead

Sorry, i dont get it, can you give me an example?

shargon commented 1 month ago

It must be the native contract initialization, use CreateGasWatcher instead

Sorry, i dont get it, can you give me an example?

Done

shargon commented 1 month ago

Maybe we can substract the native cost initialization from the engine

shargon commented 1 month ago

@Jim8y take a look to https://github.com/neo-project/neo-devpack-dotnet/pull/1078

shargon commented 1 month ago

Why still so high?

Jim8y commented 1 month ago

@shargon fixed and updated.

Jim8y commented 1 month ago

@shargon good to go now

Jim8y commented 1 month ago

This pr contains new unit tests that increases the coverage, should be merged before other prs.