Changing abi tests to use fixed bytes type

This commit is contained in:
Lefteris Karapetsas 2015-03-13 11:22:59 +01:00
parent 6554479d43
commit 760634a1cd
2 changed files with 15 additions and 123 deletions

View File

@ -227,56 +227,6 @@ describe('abi', function() {
}); });
it('should parse input hash', function() {
// given
var d = clone(description);
d[0].inputs = [
{ type: "hash" }
];
// when
var parser = abi.inputParser(d);
// then
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
});
it('should parse input hash256', function() {
// given
var d = clone(description);
d[0].inputs = [
{ type: "hash256" }
];
// when
var parser = abi.inputParser(d);
// then
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
});
it('should parse input hash160', function() {
// given
var d = clone(description);
d[0].inputs = [
{ type: "hash160" }
];
// when
var parser = abi.inputParser(d);
// then
assert.equal(parser.test("0x407d73d8a49eeb85d32cf465507dd71d507100c1"), "000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1");
});
it('should parse input address', function () { it('should parse input address', function () {
// given // given
@ -294,13 +244,13 @@ describe('abi', function() {
}); });
it('should parse input string', function () { it('should parse input fixed bytes type', function () {
// given // given
var d = clone(description); var d = clone(description);
d[0].inputs = [ d[0].inputs = [
{ type: "string" } { type: "bytes32" }
]; ];
// when // when
@ -318,14 +268,14 @@ describe('abi', function() {
); );
}); });
it('should parse input int followed by a string', function () { it('should parse input int followed by a fixed bytes type', function () {
// given // given
var d = clone(description); var d = clone(description);
d[0].inputs = [ d[0].inputs = [
{ type: "int" }, { type: "int" },
{ type: "string" } { type: "bytes32" }
]; ];
// when // when
@ -340,13 +290,13 @@ describe('abi', function() {
); );
}); });
it('should parse input string followed by an int', function () { it('should parse input fixed bytes type followed by an int', function () {
// given // given
var d = clone(description); var d = clone(description);
d[0].inputs = [ d[0].inputs = [
{ type: "string" }, { type: "bytes32" },
{ type: "int" } { type: "int" }
]; ];
@ -391,8 +341,8 @@ describe('abi', function() {
},{ },{
name: "test2", name: "test2",
type: "function", type: "function",
inputs: [{ type: "string" }], inputs: [{ type: "bytes32" }],
outputs: [{ type: "string" }] outputs: [{ type: "bytes32" }]
}]; }];
// when // when

View File

@ -21,13 +21,13 @@ var description = [{
describe('abi', function() { describe('abi', function() {
describe('outputParser', function() { describe('outputParser', function() {
it('should parse output string', function() { it('should parse output fixed bytes type', function() {
// given // given
var d = clone(description); var d = clone(description);
d[0].outputs = [ d[0].outputs = [
{ type: "string" } { type: "bytes32" }
]; ];
// when // when
@ -181,64 +181,6 @@ describe('abi', function() {
assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16); assert.equal(parser.test("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0")[0], -16);
}); });
it('should parse output hash', function() {
// given
var d = clone(description);
d[0].outputs = [
{ type: 'hash' }
];
// when
var parser = abi.outputParser(d);
// then
assert.equal(
parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it('should parse output hash256', function() {
// given
var d = clone(description);
d[0].outputs = [
{ type: 'hash256' }
];
// when
var parser = abi.outputParser(d);
// then
assert.equal(
parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
});
it('should parse output hash160', function() {
// given
var d = clone(description);
d[0].outputs = [
{ type: 'hash160' }
];
// when
var parser = abi.outputParser(d);
// then
assert.equal(
parser.test("0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1")[0],
"0x000000000000000000000000407d73d8a49eeb85d32cf465507dd71d507100c1"
);
// TODO shouldnt' the expected hash be shorter?
});
it('should parse output address', function() { it('should parse output address', function() {
// given // given
@ -317,14 +259,14 @@ describe('abi', function() {
}); });
it('should parse multiple output strings', function() { it('should parse multiple output fixed bytes type', function() {
// given // given
var d = clone(description); var d = clone(description);
d[0].outputs = [ d[0].outputs = [
{ type: "string" }, { type: "bytes32" },
{ type: "string" } { type: "bytes32" }
]; ];
// when // when
@ -380,8 +322,8 @@ describe('abi', function() {
},{ },{
name: "test2", name: "test2",
type: "function", type: "function",
inputs: [{ type: "string" }], inputs: [{ type: "bytes32" }],
outputs: [{ type: "string" }] outputs: [{ type: "bytes32" }]
}]; }];
// when // when