Skip to content

new Testing environment#890

Merged
shargon merged 112 commits intomasterfrom
core-create-artifacts
Feb 13, 2024
Merged

new Testing environment#890
shargon merged 112 commits intomasterfrom
core-create-artifacts

Conversation

@shargon
Copy link
Member

@shargon shargon commented Feb 9, 2024

Part of #889
Require neo-project/neo#3134 #892

@shargon shargon mentioned this pull request Feb 9, 2024
6 tasks

The currently known limitations are:

- Receive events during the deploy, because the object is returned after performing the deploy, it is not possible to intercept notifications for the deploy unless the contract is previously created with `FromHash` knowing the hash of the contract to be created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good to known.
Later, maybe we could create a function to facilitate with an example of a calculation of a hash and the track of this event.

@vncoelho
Copy link
Member

image

@shargon, updated devcontainer here to facilitate the verification of tests

@vncoelho
Copy link
Member

@shargon,

Is the solution file correct?

Should not it be more clean, because everything from the submodule is being added there.

@cschuchardt88
Copy link
Member

cschuchardt88 commented Feb 12, 2024

neo-express has something you want to look at for testing contracts. It work very well. Currently still works and what i been using. It is written for the testing framework XUint. However still think the testing environment should plugin into a test framework. Either mstests or XUint, 100% not NUnit

https://github.com/neo-project/neo-express/tree/master/src/test-harness

@shargon
Copy link
Member Author

shargon commented Feb 12, 2024

neo-express has something you want to look at for testing contracts. It work very well. Currently still works and what i been using. It is written for the testing framework XUint. However still think the testing environment should plugin into a test framework. Either mstests or XUint, 100% not NUnit

https://github.com/neo-project/neo-express/tree/master/src/test-harness

I can take ideas about stacked invocations, thanks!

@cschuchardt88
Copy link
Member

cschuchardt88 commented Feb 12, 2024

stacked invocations

https://github.com/neo-project/neo-express/tree/master/src/assertions ?

Collecting Code Coverage Data - https://github.com/neo-project/neo-express/tree/master/src/collector? Could use this for contract code coverage

If any of that helps.

@shargon
Copy link
Member Author

shargon commented Feb 12, 2024

Collecting Code Coverage Data - https://github.com/neo-project/neo-express/tree/master/src/collector? Could use this for contract code coverage

If any of that helps.

I think it is feasible to calculate the coverage, and the NeoDebugInfo class can make it much easier for me, I will implement it in a next version :)

Copy link
Member

@cschuchardt88 cschuchardt88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really think you should look into a mocking framework like moq. However it looks good, could be great but a great start. After questions answered or no more changes I will approve.

EDIT:

Fix #890 (comment) or explain in document

@shargon
Copy link
Member Author

shargon commented Feb 13, 2024

@cschuchardt88 @Jim8y merge? I will improve it in a new PR (Gas cost per instruction and method)

@cschuchardt88
Copy link
Member

👍 💯
I'm good with it.

I'll be adding the .editorconfig from neo to this repo soon. But 1st i have to enforce the rules in neo.

@shargon shargon merged commit 022aed5 into master Feb 13, 2024
@shargon shargon deleted the core-create-artifacts branch February 13, 2024 12:01
@shargon
Copy link
Member Author

shargon commented Feb 13, 2024

I need this merged to continue working on, Improvements can be incorporated in future pull requests.

Copy link
Member

@vncoelho vncoelho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished reviewing today.

Jim8y pushed a commit that referenced this pull request Aug 3, 2025
* Creating source from nef
* change to LF
* Fix _deploy in NEP17 template
* change comment
* Replace SetOwner
* Remove extra file
* Remove _deploy and _initialize
* change to _
* Add args
* Separate safe from unsafe
* abstract Class
* format
* Only source
* Generate events
* Mock
* starting native artifacts
* CryptoLib
* Rename project to avoid old one
* LF
* Escape name
* Avoid generation native artifacts
* TestNativeContracts
* Redirect Logs and Notifications to the mocked smart contract
* Mock notifications
* Converts
* format
* LoadFromJson
* Initialize native contracts
* Partially mocked
* Mocked with args
* Fix Scope
* Found bug in MemoryStore
* TriggerType.Application
* clean and fixes
* format
* Remove utartifact
* Fix FromHash
* Clean code
* Store current script in transaction
* Allow to set the Gas
* Clean code
* Reduce changes
* Change Snapshot
* Change to Artifact to ArtifactExtensions
* Clean code
* Move to Extensions folder
* Fix Native initialization
* Allow Custom mocks
* Format
* some vars
* Add some summaries
* Allow to mock undeployed contracts
* Test undeployed mocked contracts
* Change init native to true by default
* Clean using
* Allow null in deploy
* Modify ContractManagement artifact
* Readme
* Fix menu
* Resume example using native access
* Clean storage example
* fix readme
* Fix readme
* Fix readme and move CommitteeAddress
* Add event testing to readme
* Allow properties!
* Allow properties if the method is without args and safe
* User uppercase for first letter (conflicts with events and methods in native contracts)
* All events start with "On" (avoid native conflicts)
* Rename log event
* Avoid re-query contract id if it was checked
* format
* Update Readme examples
* Improve Mock.OnSysCall
* Some small changes
* Generate compiled artifacts (.dll)
* LF
* is 3 not 2
* Update src/Neo.SmartContract.Testing/README.md
* Update src/Neo.SmartContract.Testing/NativeArtifacts.cs
* Sign by default with Validators and committee
* Rename to ValidatorsAddress
* Allow to get address without initialize
* Clean comment
* Allow deploy with byte[]
* allow null on deploy and update
* Update readme
* Fix static event
* Allow native init notifications
* Belane's feedback
* Nullable when ends in object argument
* Speedup InvokeOnNotify
* Increase protected words
* Allow Export and Import contract storage
* format
* Fix summary
* Known limitations
* Fix comments
* Fix "Value" string
* devcontainer ready for testing PR
* Revert "devcontainer ready for testing PR"
This reverts commit 04cc1ef.
* Add more ways to set the signers easy
* Avoid base64 strings
* cschuchardt88's feedback
* Change to IList when Array
* Clean Check initialized
---------
Co-authored-by: Vitor Nazario Coelho <vncoelho@gmail.com>
Jim8y pushed a commit that referenced this pull request Aug 18, 2025
* Creating source from nef

* change to LF

* Fix _deploy in NEP17 template

* change comment

* Replace SetOwner

* Remove extra file

* Remove _deploy and _initialize

* change to _

* Add args

* Separate safe from unsafe

* abstract Class

* format

* Only source

* Generate events

* Mock

* starting native artifacts

* CryptoLib

* Rename project to avoid old one

* LF

* Escape name

* Avoid generation native artifacts

* TestNativeContracts

* Redirect Logs and Notifications to the mocked smart contract

* Mock notifications

* Converts

* format

* LoadFromJson

* Initialize native contracts

* Partially mocked

* Mocked with args

* Fix Scope

* Found bug in MemoryStore

* TriggerType.Application

* clean and fixes

* format

* Remove utartifact

* Fix FromHash

* Clean code

* Store current script in transaction

* Allow to set the Gas

* Clean code

* Reduce changes

* Change Snapshot

* Change to Artifact to ArtifactExtensions

* Clean code

* Move to Extensions folder

* Fix Native initialization

* Allow Custom mocks

* Format

* some vars

* Add some summaries

* Allow to mock undeployed contracts

* Test undeployed mocked contracts

* Change init native to true by default

* Clean using

* Allow null in deploy

* Modify ContractManagement artifact

* Readme

* Fix menu

* Resume example using native access

* Clean storage example

* fix readme

* Fix readme

* Fix readme and move CommitteeAddress

* Add event testing to readme

* Allow properties!

* Allow properties if the method is without args and safe

* User uppercase for first letter (conflicts with events and methods in native contracts)

* All events start with "On" (avoid native conflicts)

* Rename log event

* Avoid re-query contract id if it was checked

* format

* Update Readme examples

* Improve Mock.OnSysCall

* Some small changes

* Generate compiled artifacts (.dll)

* LF

* is 3 not 2

* Update src/Neo.SmartContract.Testing/README.md

* Update src/Neo.SmartContract.Testing/NativeArtifacts.cs

* Sign by default with Validators and committee

* Rename to ValidatorsAddress

* Allow to get address without initialize

* Clean comment

* Allow deploy with byte[]

* allow null on deploy and update

* Update readme

* Fix static event

* Allow native init notifications

* Belane's feedback

* Nullable when ends in object argument

* Speedup InvokeOnNotify

* Increase protected words

* Allow Export and Import contract storage

* format

* Fix summary

* Known limitations

* Fix comments

* Fix "Value" string

* devcontainer ready for testing PR

* Revert "devcontainer ready for testing PR"

This reverts commit 04cc1ef.

* Add more ways to set the signers easy

* Avoid base64 strings

* cschuchardt88's feedback

* Change to IList when Array

* Clean Check initialized

---------

Co-authored-by: Vitor Nazario Coelho <vncoelho@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants