mirror of
https://github.com/wassname/catalyst.git
synced 2026-06-28 19:47:13 +08:00
BLD: removed dummy smart contract
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
This module contains smart contracts for the data marketplace.
|
||||
It was generated with Truffle. Truffle can be used to compile and test
|
||||
the smart contracts. It's being tested on a test blockhain using Ganache.
|
||||
|
||||
Steps to test:
|
||||
* Download and run Ganache
|
||||
* Ensure that your Ganache endpoint matches `truffle.js`
|
||||
* In this `marketplace` folder, run the following commands:
|
||||
* `truffle compile`
|
||||
* `truffle test`
|
||||
* `truffle migrate --reset`
|
||||
* `truffle console`
|
||||
* From the console: `Marketplace.deployed()`
|
||||
* The deployed method displays info about the deployed smart contract
|
||||
including its address. Copy/paste the address into
|
||||
`catalyst/marketplace/marketplace.py`.
|
||||
* Run the catalyst marketplace unit tests:
|
||||
`tests/marketplace/test_marketplace.py`
|
||||
@@ -1,19 +0,0 @@
|
||||
pragma solidity ^0.4.17;
|
||||
|
||||
contract Marketplace {
|
||||
address[16] public subscribers;
|
||||
|
||||
// Subscribing to a data source
|
||||
function subscribe(uint dataSourceId) public returns (uint) {
|
||||
require(dataSourceId >= 0 && dataSourceId <= 15);
|
||||
|
||||
subscribers[dataSourceId] = msg.sender;
|
||||
|
||||
return dataSourceId;
|
||||
}
|
||||
|
||||
// Retrieving the subscribers
|
||||
function getSubscribers() public view returns (address[16]) {
|
||||
return subscribers;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
pragma solidity ^0.4.17;
|
||||
|
||||
contract Migrations {
|
||||
address public owner;
|
||||
uint public last_completed_migration;
|
||||
|
||||
modifier restricted() {
|
||||
if (msg.sender == owner) _;
|
||||
}
|
||||
|
||||
function Migrations() public {
|
||||
owner = msg.sender;
|
||||
}
|
||||
|
||||
function setCompleted(uint completed) public restricted {
|
||||
last_completed_migration = completed;
|
||||
}
|
||||
|
||||
function upgrade(address new_address) public restricted {
|
||||
Migrations upgraded = Migrations(new_address);
|
||||
upgraded.setCompleted(last_completed_migration);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="WEB_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="Python" name="Python">
|
||||
<configuration sdkName="Python 3.6.3 virtualenv at ~/Code/enigma/catalyst/python3" />
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Python 3.6.3 virtualenv at ~/Code/enigma/catalyst/python3 interpreter library" level="application" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,5 +0,0 @@
|
||||
var Migrations = artifacts.require("./Migrations.sol");
|
||||
|
||||
module.exports = function(deployer) {
|
||||
deployer.deploy(Migrations);
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
var Marketplace = artifacts.require ("Marketplace");
|
||||
|
||||
module.exports = function (deployer) {
|
||||
deployer.deploy (Marketplace);
|
||||
};
|
||||
@@ -1,39 +0,0 @@
|
||||
pragma solidity ^0.4.17;
|
||||
|
||||
import "truffle/Assert.sol";
|
||||
import "truffle/DeployedAddresses.sol";
|
||||
import "../contracts/Marketplace.sol";
|
||||
|
||||
contract TestMarketplace {
|
||||
Marketplace marketplace = Marketplace(DeployedAddresses.Marketplace());
|
||||
|
||||
// Testing the subscribe() function
|
||||
function testUserCanSubscribe() public {
|
||||
uint returnedId = marketplace.subscribe(2);
|
||||
|
||||
uint expected = 2;
|
||||
|
||||
Assert.equal(returnedId, expected, "Data source 2 should be recorded.");
|
||||
}
|
||||
|
||||
// Testing retrieval of a single subscriber
|
||||
function testGetSubscriberAddressByDataSourceId() public {
|
||||
// Expected owner is this contract
|
||||
address expected = this;
|
||||
|
||||
address subscriber = marketplace.subscribers(2);
|
||||
|
||||
Assert.equal(subscriber, expected, "Subscriber of data source ID 2 should be recorded.");
|
||||
}
|
||||
|
||||
// Testing retrieval of all subscribers
|
||||
function testGetSubscriberAddressByDataSourceIdInArray() public {
|
||||
// Expected subscriber is this contract
|
||||
address expected = this;
|
||||
|
||||
// Store subscribers in memory rather than contract's storage
|
||||
address[16] memory subscribers = marketplace.getSubscribers();
|
||||
|
||||
Assert.equal(subscribers[2], expected, "Subscriber of data source 2 should be recorded.");
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
module.exports = {
|
||||
// See <http://truffleframework.com/docs/advanced/configuration>
|
||||
// to customize your Truffle configuration!
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
module.exports = {
|
||||
// See <http://truffleframework.com/docs/advanced/configuration>
|
||||
// to customize your Truffle configuration!
|
||||
networks: {
|
||||
development: {
|
||||
host: "localhost",
|
||||
port: 7545,
|
||||
network_id: "*" // Match any network id
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user