Visual Studio Solidity Demo Project

After messing around with Ethereum, a decentralized platform for applications based on bitcoin, I developed a simple project in Visual Studio to help me run and debug contracts (applications/programs that run on Ethereum). This project is a Node.js project and connects to testrpc to run the contracts. 

The project needs to be be commented but should be quite straight forward.

Project Directory

The project directory contains 3 important files (app.js, config.json and info.txt) and 2 important folders (contracts and tests).

App.js is the main project file and contains the code that compiles and runs the contracts and then starts the testing. Config.json is a json file with all of the information needed for app.js to load the contracts. In this file you define what contracts to run, what their constructors are and what test file you should use to test it. Info.txt contains a command to run testrpc and a list of accounts and private keys that will be created when it starts that can be used.

The contracts folder is for storing all of your solidity source files and the tests folder is for storing all of your test files.

Testing

When you run the project, it will compile and deploy the contracts outlined in the config file and then pass them to their corresponding test programs.

I have written a simple test library similar to the node js assert but will print the output to the console. First call 'assert.test("test case");' to log what function you are testing and then 'assert.that("part");' to log what part of that function output your testing and then the assert function you are testing with. All these of functions can be chained together. For a full list of functionality look at the source at /node_modules/unitTest.js.

Config

default config.

{
  "server": {
    "host": "http://localhost",
    "port": 8545
  },
  "contracts": [
    {
      "file":"test.sol",
      "constructor": [ "0xcd6ccc877d642ce8fff4da904db0013f137848ef" ],
      "test": "test.js"
    }
  ]
}

Editing

The solidity files do not have highlighting or code completion so I suggest either writing the contracts in the browser IDE or Visual Studio Code (with the highlighting extension installed) and then testing. 

Download: here

Ethereum: here
Solidity: here
TestRPC: here
Browser IDE: here

Visual Studio Node.js: here
Visual Studio Code Highlighting: here