[Ethereum] How to send bytes in combination with array to contract

contract-developmentgo-ethereumsolidity

I see strange behavior when I try to execute some test contracts. I have made 2 test contracts,

contract TestContract1 {
        uint public n;
        uint public testValue1;
        bytes6 public value;

        function TestContract1(bytes6 val, uint[] testArray) {
                n = testArray.length;
                testValue1 = testArray[0];
                value = val;
        }
}

and

contract TestContract4 {
        uint public n;
        uint public testValue1;
        uint public value;

        function TestContract4(uint val, uint[] testArray) {
                n = testArray.length;
                testValue1 = testArray[0];
                value = val;
        }
}

These contracts are identical, except for the val, parameter, which is a uint in TestContract4 and bytes6 in TestContract1.

I execute contract #4 by the following code from geth:

var testContract = web3.eth.contract(abiArray);
var test = testContract.new(
   0x313131314141, [123,456], 
   {
     data:contractCode,
     from: eth.accounts[0],
     gas: 1000000
   }, function(e, contract){
    console.log(e, contract);
    if (typeof contract.address != 'undefined') {
         console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);
    }
 });

and I look at the different variables stored in the contract, all values are correctly stored and retrieved (i.e. n = 2, testValue1 = 123, value = 54087348470081).

When I execute contract #1 with the same code from geth, I get a correct value = 0x313131314141, but n and testValue1 have strange values (n = 10696049115004928, testValue1 = 562949953421312).

Can anyone tell me what's happening here? I.e. why runs the contract correctly when I define the first parameter as an uint and behaves strange when I specify it as a bytes6 type?

Thanks in advance.

Best Answer

It may be a Geth bug because a quick test in Solidity Browser appears to work correctly .

enter image description here