These are chat archives for Nethereum/Nethereum

15th
May 2018
Psilon
@Pzixel
May 15 2018 08:51
Here I am again
here's my test:
[Fact]
public async Task Should_ChangeTrackableStatus()
{
    var web3 = TestHelper.GetWeb3();
    var factory = await SeasonFactory.DeployAsync(web3);
    var season = await factory.CreateSeasonAsync(DateTimeOffset.UtcNow, DateTimeOffset.UtcNow.AddDays(1));
    var request = await season.CreateRequestAsync("123");

    var trackableStatus = new StatusUpdate(DateTimeOffset.UtcNow, Request.TrackableStatuses.First(), "Trackable status");
    var nonTrackableStatus = new StatusUpdate(DateTimeOffset.UtcNow, 0, "Nontrackable status");

    await request.UpdateStatusAsync(trackableStatus);
    await request.UpdateStatusAsync(nonTrackableStatus);

    var statuses = await request.GetStatusesAsync();

    Assert.Single(statuses);
    Assert.Equal(trackableStatus, statuses.Single());
    _output.WriteLine(factory.Address);
}
and here is my contract
it's quite big
but I don't know what's wrong here
when I call UpdateStatusAsync
I get following receipt
{"transactionHash":"0x0d9243af09d4f07c3ee5a54e78b2b14ae9b50e5ea56ead902893ce62c7e58182","transactionIndex":"0x0","blockHash":"0xafe2e531c20bb9262914e69547f3b66354a765d9e69c3b215d901c8411deca6a","blockNumber":"0xa7d","cumulativeGasUsed":"0x5db9","gasUsed":"0x5db9","contractAddress":null,"status":"0x0","logs":[]}
wait a minute
JIREN-EXCHANGE
@JIREN-EXCHANGE
May 15 2018 09:01
Hey @juanfranblanco . Okay, I absolutely need to implement this HDWallet feature today at work. I've seen how the HD Wallet package works in NEThereum my only issue is generating the word list
Juan Blanco
@juanfranblanco
May 15 2018 09:02
just pass a the WordList
as in WordList.English
and let the NBitcoin magic do the rest
or mainly use NBitcoin and use your own custom Random
@Pzixel you maybe are not putting enough bas
gas*
JIREN-EXCHANGE
@JIREN-EXCHANGE
May 15 2018 09:04
Cool. thanks @juanfranblanco . Thanks for the awsome work you put into this Library and community
Juan Blanco
@juanfranblanco
May 15 2018 09:05
@JIREN-EXCHANGE you are very welcome and thanks for the feedback :)
Psilon
@Pzixel
May 15 2018 09:29
@juanfranblanco no, i'm putting enough. It looks like it really fails this transaction
I'm doing git bisect to find an evil doer
Juan Blanco
@juanfranblanco
May 15 2018 09:30
remove the requires
require(seasons.length == 0 || Season(seasons[seasons.length - 1]).end() < begin);
it might be something there
Psilon
@Pzixel
May 15 2018 09:32
contract is fine
I changed something in C# code
Juan Blanco
@juanfranblanco
May 15 2018 09:32
i mean on the params
Psilon
@Pzixel
May 15 2018 09:32
I mean test is passing fine on master branch with same contract
something changed on C# side and broke the code
I started to type
but then realised that query actually doesn't work
and 0 is a valid result as it didn't work well
so I started to investigate
and this is why I said "wait a minute"
Juan Blanco
@juanfranblanco
May 15 2018 09:33
ah..
Celestral
@Celestral
May 15 2018 09:54
Hi! I need to sign a transaction and all guides and answers online lead to web3.OfflineTransactionSigning, but that doesn't seem to exist anymore. What should I use in its place?
Juan Blanco
@juanfranblanco
May 15 2018 09:54
use Web3.OfflineTransactionSigning
Celestral
@Celestral
May 15 2018 09:54
Ah ok thanks!
Juan Blanco
@juanfranblanco
May 15 2018 10:09
@Pzixel
Well testing this
pragma solidity ^0.4.23;

contract Owned {
    address public owner;

    constructor() public { 
        owner = msg.sender;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    function isDeployed() public pure returns(bool) {
        return true;
    }
}

contract Season {
    uint64 _begin;
    uint64 _end;

    constructor(uint64 begin, uint64 end) public {
        _begin = begin;
        _end = end;
    }

    function end() public view returns (uint64) {
        return _end;
    }
}

contract SeasonFactory is Owned {

    address[] public seasons;

    event SeasonCreated(uint64 indexed begin, uint64 indexed end, address season);

    function createSeason(uint64 begin, uint64 end) public onlyOwner {
        require(begin < end);
        require(seasons.length == 0 || Season(seasons[seasons.length - 1]).end() < begin);

        Season season = new Season(begin, end);
        seasons.push(season);
        emit SeasonCreated(begin, end, season);
    }
}
with this..

namespace SolditySamples.Contracts.SeasonFactory
{
    public class SeasonFactoryContractTest : NethereumIntegrationTest
    {
        public SeasonFactoryContractTest(ITestOutputHelper xunitTestOutputHelper) : base("http://localhost:8545",
            DefaultTestAccountConstants.PrivateKey,
            new NethereumTestDebugLogger(new XunitOutputWriter(xunitTestOutputHelper)))
        {

        }

        [Fact]
        public async Task ShouldRaisedSeasonCreatedEvent_AfterCreateSeason()
        {
            var contractDeploymentDefault = new SeasonFactoryDeployment()
            {
                FromAddress = DefaultTestAccountConstants.Address,
            };

            GivenADeployedContract(contractDeploymentDefault);

            var createSeasonFunction = new CreateSeasonFunction()
            {
               Begin = 1,
               End = 2

            };

            var expectedEvent = new SeasonCreatedEventDTO()
            {
                Begin = 1,
                End = 2
            };

            var receipt = GivenATransaction(createSeasonFunction);

            var seasonCreated = receipt.GetFirstEventOutput<SeasonCreatedEventDTO>();
            Assert.Equal(expectedEvent.Begin, seasonCreated.Begin);
            Assert.Equal(expectedEvent.End, seasonCreated.End);
            Assert.NotNull(seasonCreated.Season);
        }

    }

    public static class TransactionResultExtensions
    {
        public static TEventDTO GetFirstEventOutput<TEventDTO>(this TransactionResult transactionResult) where TEventDTO : new()
        {
            //transactionResult.TestLogger.LogExpectedEvent(expectedEvent);

            var eventItem = transactionResult.ContractHandler.GetEvent<TEventDTO>();
            var eventFirst = eventItem.DecodeAllEventsForEvent<TEventDTO>(transactionResult.TransactionReceipt.Logs).FirstOrDefault();


            transactionResult.TestLogger.LogExpectedEvent(eventFirst);

            return eventFirst.Event;
        }

    }
}
it is all fine
btw this uses the Nethereum.Contracts.IntegrationTester
and great feedback (needs more extensions)
Psilon
@Pzixel
May 15 2018 10:18
I found the evil commit
I actually don't know how it affects
when I'm done I'l try to provide more feedback
Juan Blanco
@juanfranblanco
May 15 2018 10:23
on that note Nethereum/Nethereum.Contracts.IntegrationTester#8
JIREN-EXCHANGE
@JIREN-EXCHANGE
May 15 2018 11:31
@juanfranblanco I got the HdWallet to work. What's the max number of addresses i can generate for a particular mnemonic word phrase
Psilon
@Pzixel
May 15 2018 11:50
@juanfranblanco yeah, I found my stupid mistake
image.png
Sorry for bothering
Juan Blanco
@juanfranblanco
May 15 2018 12:42
@JIREN-EXCHANGE i believe up to 2000 based on conversations with Christian from uport
@Pzixel don't worry you should be better off using vanilla, maintenance, fixes, new stuff
and support :)
Psilon
@Pzixel
May 15 2018 12:44
:P
The main problem is that if I have some kind of createRequest I cannot get an address from it
I have to fire an event or query it again)
no way to getorcreate
Juan Blanco
@juanfranblanco
May 15 2018 12:45
but It has been very helpful as I realised so many improvements are needed for the unit testing
you mean using the factory
yeah
check what I have done here
var seasonCreated = receipt.GetFirstEventOutput<SeasonCreatedEventDTO>();
            Assert.Equal(expectedEvent.Begin, seasonCreated.Begin);
            Assert.Equal(expectedEvent.End, seasonCreated.End);
            Assert.NotNull(seasonCreated.Season);
using something like
eventItem.DecodeAllEventsForEvent<TEventDTO>(transactionResult.TransactionReceipt.Logs).FirstOrDefault();
Psilon
@Pzixel
May 15 2018 12:50
hmm
so you can get this information form logs?
that would really great
Juan Blanco
@juanfranblanco
May 15 2018 12:51
yep
check the unit test
it mainly verifies
the begin and end match
and also extract the address
and assert for null
(just realised i am just describing 3 lines above)
Psilon
@Pzixel
May 15 2018 12:53
cool
going to try it right now! :)
Juan Blanco
@juanfranblanco
May 15 2018 12:56
that is a unit test type
just use the receipt
Psilon
@Pzixel
May 15 2018 12:57
Yep, I realized it right now
Receipt doesn't have an event item
Juan Blanco
@juanfranblanco
May 15 2018 12:57
it is mainly used to be able to have a fluent syntax on checks
yeah
you need to create an event
ie..
contract.GetEvent("name");
or
contractHandler.GetEvent<Type>();
and use the event
to do the rest
Psilon
@Pzixel
May 15 2018 13:02
Thankfully I already have one
thank you, I'l give it a try a bit later
I have to fix some blockers right now :D