Skip to content

Commit

Permalink
Merge pull request #86 from CoinageCrypto/fix-tests
Browse files Browse the repository at this point in the history
Making tests run and pass.
  • Loading branch information
thekevinbrown authored Sep 26, 2019
2 parents 30e29ba + 5899bbb commit 24e9d97
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .lamington/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

data/
compiled_contracts/
9 changes: 9 additions & 0 deletions .lamingtonrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"cdt": "https://github.com/EOSIO/eosio.cdt/releases/download/v1.6.2/eosio.cdt_1.6.2-1-ubuntu-18.04_amd64.deb",
"eos": "https://github.com/EOSIO/eos/releases/download/v1.8.4/eosio_1.8.4-1-ubuntu-18.04_amd64.deb",
"debug": 0,
"debugTransactions": false,
"keepAlive": false,
"outDir": ".lamington",
"exclude": []
}
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
src/
node_modules/
api-docs/
.lamington/
.lamingtonrc
contracts/
.gitignore
.prettierrc
.travis.yml
Expand Down
37 changes: 37 additions & 0 deletions contracts/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <eosio/eosio.hpp>
#include <string>

using namespace eosio;
using namespace std;

class[[eosio::contract("example")]] example : public contract
{

public:
using contract::contract;

[[eosio::action]] void post(const name author, const string message) {
// Ensure author is signee
require_auth(author);
// Initialize a message table instance
message_table messages(_self, _self.value);
// Store the new message for author
messages.emplace(author, [&](auto &post) {
post.id = messages.available_primary_key();
post.body = message;
post.author = author;
});
}

private :

struct [[eosio::table]] MessageStruct {
uint64_t id;
string body;
name author;

uint64_t primary_key() const { return id; };
};

typedef multi_index<"messages"_n, MessageStruct> message_table;
};
23 changes: 23 additions & 0 deletions contracts/example.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// =====================================================
// WARNING: GENERATED FILE
//
// Any changes you make will be overwritten by Lamington
// =====================================================

import { Account, Contract, GetTableRowsOptions, TableRowsResult } from 'lamington';

// Table row types
export interface ExampleMessages {
id: number;
body: string;
author: string|number;
}

export interface Example extends Contract {
// Actions
post(author: string|number, message: string, options?: { from?: Account }): Promise<any>;

// Tables
messages(options?: GetTableRowsOptions): Promise<TableRowsResult<ExampleMessages>>;
}

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
"clean": "rm -rf ./lib",
"docs": "typedoc --out api-docs ./src",
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
"lamington:init": "lamington init",
"prepublishOnly": "npm test",
"prepare": "npm run build",
"test": "mocha --require ts-node/register src/**/*.test.ts"
"test": "TS_NODE_FILES=true mocha --require ts-node/register src/**/*.test.ts"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -47,8 +48,8 @@
],
"devDependencies": {
"@types/chai": "4.2.3",
"@types/mkdirp": "0.5.2",
"@types/mocha": "5.2.7",
"@types/mkdirp": "0.5.2",
"@types/ncp": "^2.0.1",
"@types/node": "12.7.7",
"@types/node-fetch": "2.5.2",
Expand Down
2 changes: 1 addition & 1 deletion src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const buildImage = async () => {
`
FROM ubuntu:18.04
RUN apt-get update && apt-get install -y --no-install-recommends wget curl ca-certificates
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends wget curl ca-certificates
RUN wget ${ConfigManager.cdt} && apt-get install -y ./*.deb && rm -f *.deb
RUN wget ${ConfigManager.eos} && apt-get install -y ./*.deb && rm -f *.deb
RUN apt-get clean && rm -rf /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/*
Expand Down
4 changes: 0 additions & 4 deletions src/contracts/typeGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,5 @@ describe('type generator', function() {
await stopContainer();
}
});

it('should generate an expected result from the eosio.token contract file', async function() {
console.log('yup');
});
});
});

0 comments on commit 24e9d97

Please sign in to comment.