Giter VIP home page Giter VIP logo

Comments (21)

shargon avatar shargon commented on July 17, 2024 2

https://github.com/neo-project/neo-devpack-dotnet/blob/master/src%2FNeo.SmartContract.Testing%2FREADME.md please tell me if you need more information

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024 1

IIUC that'd be something similar to https://pkg.go.dev/github.com/nspcc-dev/neo-go/pkg/neotest or https://neow3j.io/#/neo-n3/smart_contract_development/testing. But both have some real or almost real ledger behind, so invocations are real transactions packed into some blocks and processed in a regular way. Can you you provide more details on how DLL-packed contracts will work here?

The problem that we have been encountering throughout all the contracts reviewed is mainly the same, the contracts have not been tested, and the lack of unit tests.

What I am doing is the ability to generate some "artifacts" abstract class extracted from NefFile, in this way the testing is not limited to contracts made in C#, these artifacts generate a valid C# code descriptive of the Abi, and through mocks, I intend convert types between VM<>dotnet to facilitate calling and testing contracts.

The initial idea (it may evolve in a future version) is to test without generating a transaction, so if you want to simulate two transactions you would have to do something like this:

var walletA= new UInt160("a");
var walletA= new UInt160("b");
TestEngine engine=new ();

var contract = engine.Deploy<MyContract>();

engine.Signer= walletA;
contract.Mint();

engine.Signer= walletB;
Assert.IsFalse(contract.Transfer(walletA,walletB,1)); // no signed by a

engine.Signer= walletA;
Assert.IsTrue(contract.Transfer(walletA,walletB,1));

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024 1

@shargon can you add checkpoints to your engine?

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

I will be creating an DebugApplicationEngine. After my TraceApplicationEngine. Just keep that in mind.

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

I will be creating an DebugApplicationEngine. After my TraceApplicationEngine. Just keep that in mind.

The underlying engine could be changed in a future easily in order to be more verbose.

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

I will be creating an DebugApplicationEngine. After my TraceApplicationEngine. Just keep that in mind.

The underlying engine could be changed in a future easily in order to be more verbose.

I already did that. Im not changing ApplicationEngine. I am however replacing it by doing ApplicationEngine.Provider = new TraceApplicationEngine());

All I am saying is, all this work you are doing can be done very easy with current code we have. It already built to handle something like this. I don't know why you reinventing the wheel again. When we have already made it.

image
image

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

I don't know why you reinventing the wheel again. When we have already made it.

I'm tired of seeing projects in neo without any unit tests, it's not easy to do them, show me a single project that has them, I think this wheel is not even being reinvented, if it is even designed.

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

Your misunderstanding it. I explained it incorrectly.

The TestEngine you are creating. Can be done with ease with IApplicationEngineProvider. All I am saying is build your Engine with that Interface. So you can plugin/hook into the ApplicationEngine protected or virtual methods for getting all the VMs information. I don't think I need to tell you the information you can get from ApplicationEngine. But this would be the real big test. Where you can test on mainnet or testnet without problems. I been working on TraceApplicationEngine for about a day. And was saying no one should reinvent all the functionality that ApplicationEngine has already. We have an Engine Its called ApplicationEngine. You should make TestApplicationEngine or ContractApplicationEngine. If that makes sense.

from neo-devpack-dotnet.

roman-khimov avatar roman-khimov commented on July 17, 2024

IIUC that'd be something similar to https://pkg.go.dev/github.com/nspcc-dev/neo-go/pkg/neotest or https://neow3j.io/#/neo-n3/smart_contract_development/testing. But both have some real or almost real ledger behind, so invocations are real transactions packed into some blocks and processed in a regular way. Can you you provide more details on how DLL-packed contracts will work here?

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

Here you can see how it will work:

https://github.com/neo-project/neo-devpack-dotnet/blob/f00d32a7eae7b739cf512f9c8d735ad84af38f19/tests/Neo.SmartContract.Testing.UnitTests/NativeArtifactsTests.cs

from neo-devpack-dotnet.

Jim8y avatar Jim8y commented on July 17, 2024

would be much better if you had provided a detailed introduction on what you are trying to do, and how it is supposed to work.

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

would be much better if you had provided a detailed introduction on what you are trying to do, and how it is supposed to work.

@shargon Yes we need more information. So you dont waste everyone's time, including yours.

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

would be much better if you had provided a detailed introduction on what you are trying to do, and how it is supposed to work.

Got it, next time I will do that. My goal is to make it easy unit tests for any smart contract, because trust me, there's a lack of this everywhere.

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

would be much better if you had provided a detailed introduction on what you are trying to do, and how it is supposed to work.

Got it, next time I will do that. My goal is to make it easy unit tests for any smart contract, because trust me, there's a lack of this everywhere.

That is fine. How are we to use it? How do we build tests now? How do we setup the environment? What is required of a test? Whats the convention of the API? How are files and configuration laid out?

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

That is fine. How are we to use it? How do we build tests now? How do we setup the environment? What is required of a test? Whats the convention of the API? How are files and configuration laid out?

I will write a Readme.md explaining the new testing environment

from neo-devpack-dotnet.

Jim8y avatar Jim8y commented on July 17, 2024

@shargon can you add checkpoints to your engine?

BreakPoint? VM.Tests's engine can do that. Can be added in another pr if not added.

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

@shargon can you add checkpoints to your engine?

Only snapshots now, commit and rollback, but if you consider dump the storage to a json, and load from it a checkpoint, yes, it's possible to do that

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

Also can we have in binary file format? If not already.

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

Also can we have in binary file format? If not already.

Of course, it could be faster

from neo-devpack-dotnet.

cschuchardt88 avatar cschuchardt88 commented on July 17, 2024

Also can we have in binary file format? If not already.

Of course, it could be faster

I mean log file in binary format also.

from neo-devpack-dotnet.

shargon avatar shargon commented on July 17, 2024

I think that the testEngine is finished, let's move to the next step #949

from neo-devpack-dotnet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.