Question:

Contract deploying but not initializing state variables

Mia: 2 weeks ago

I'm deploying via Remix and Metamask.

I have an intializer function MyToken() { ... } that initializes a few state variables, and calls test(); test(); at the end.

The contract deploys, but none of the state variables get initialized. When I remove test(); test();, it works.

Why could this be? If those two calls to test() produced an error, then wouldn't the contract simply not deploy?

edit

When I deploy to "Javascript VM" rather than "Injected Web3", it works fine.

Just putting one call to test(); works fine; so is it a gas problem? Why is the contract still deploying then?

Also, calling test(); test(); manually (when it is not included in the intializer) works.

Answer:
Evelyn: 2 weeks ago

It seems that the second call to test() was pushing the transaction above the gas limit. I guess the compiler couldn't compute that function's cost beforehand, so it let me deploy it. However, the result it presented me had every value zeroed out, so I don't think it was successfully deployed.