Skip to content

Commit 24e9d97

Browse files
Merge pull request #86 from CoinageCrypto/fix-tests
Making tests run and pass.
2 parents 30e29ba + 5899bbb commit 24e9d97

File tree

9 files changed

+80
-8
lines changed

9 files changed

+80
-8
lines changed

.lamington/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
data/
3+
compiled_contracts/

.lamingtonrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"cdt": "https://github.com/EOSIO/eosio.cdt/releases/download/v1.6.2/eosio.cdt_1.6.2-1-ubuntu-18.04_amd64.deb",
3+
"eos": "https://github.com/EOSIO/eos/releases/download/v1.8.4/eosio_1.8.4-1-ubuntu-18.04_amd64.deb",
4+
"debug": 0,
5+
"debugTransactions": false,
6+
"keepAlive": false,
7+
"outDir": ".lamington",
8+
"exclude": []
9+
}

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
src/
22
node_modules/
33
api-docs/
4+
.lamington/
5+
.lamingtonrc
6+
contracts/
47
.gitignore
58
.prettierrc
69
.travis.yml

contracts/example.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <eosio/eosio.hpp>
2+
#include <string>
3+
4+
using namespace eosio;
5+
using namespace std;
6+
7+
class[[eosio::contract("example")]] example : public contract
8+
{
9+
10+
public:
11+
using contract::contract;
12+
13+
[[eosio::action]] void post(const name author, const string message) {
14+
// Ensure author is signee
15+
require_auth(author);
16+
// Initialize a message table instance
17+
message_table messages(_self, _self.value);
18+
// Store the new message for author
19+
messages.emplace(author, [&](auto &post) {
20+
post.id = messages.available_primary_key();
21+
post.body = message;
22+
post.author = author;
23+
});
24+
}
25+
26+
private :
27+
28+
struct [[eosio::table]] MessageStruct {
29+
uint64_t id;
30+
string body;
31+
name author;
32+
33+
uint64_t primary_key() const { return id; };
34+
};
35+
36+
typedef multi_index<"messages"_n, MessageStruct> message_table;
37+
};

contracts/example.ts

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// =====================================================
2+
// WARNING: GENERATED FILE
3+
//
4+
// Any changes you make will be overwritten by Lamington
5+
// =====================================================
6+
7+
import { Account, Contract, GetTableRowsOptions, TableRowsResult } from 'lamington';
8+
9+
// Table row types
10+
export interface ExampleMessages {
11+
id: number;
12+
body: string;
13+
author: string|number;
14+
}
15+
16+
export interface Example extends Contract {
17+
// Actions
18+
post(author: string|number, message: string, options?: { from?: Account }): Promise<any>;
19+
20+
// Tables
21+
messages(options?: GetTableRowsOptions): Promise<TableRowsResult<ExampleMessages>>;
22+
}
23+

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
"clean": "rm -rf ./lib",
1212
"docs": "typedoc --out api-docs ./src",
1313
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
14+
"lamington:init": "lamington init",
1415
"prepublishOnly": "npm test",
1516
"prepare": "npm run build",
16-
"test": "mocha --require ts-node/register src/**/*.test.ts"
17+
"test": "TS_NODE_FILES=true mocha --require ts-node/register src/**/*.test.ts"
1718
},
1819
"repository": {
1920
"type": "git",
@@ -47,8 +48,8 @@
4748
],
4849
"devDependencies": {
4950
"@types/chai": "4.2.3",
50-
"@types/mkdirp": "0.5.2",
5151
"@types/mocha": "5.2.7",
52+
"@types/mkdirp": "0.5.2",
5253
"@types/ncp": "^2.0.1",
5354
"@types/node": "12.7.7",
5455
"@types/node-fetch": "2.5.2",

src/cli/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const buildImage = async () => {
9797
`
9898
FROM ubuntu:18.04
9999
100-
RUN apt-get update && apt-get install -y --no-install-recommends wget curl ca-certificates
100+
RUN apt-get update --fix-missing && apt-get install -y --no-install-recommends wget curl ca-certificates
101101
RUN wget ${ConfigManager.cdt} && apt-get install -y ./*.deb && rm -f *.deb
102102
RUN wget ${ConfigManager.eos} && apt-get install -y ./*.deb && rm -f *.deb
103103
RUN apt-get clean && rm -rf /tmp/* /var/tmp/* && rm -rf /var/lib/apt/lists/*

src/contracts/typeGenerator.test.ts

-4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,5 @@ describe('type generator', function() {
111111
await stopContainer();
112112
}
113113
});
114-
115-
it('should generate an expected result from the eosio.token contract file', async function() {
116-
console.log('yup');
117-
});
118114
});
119115
});

0 commit comments

Comments
 (0)