示例#1
0
        public async Task TestMappings()
        {
            // Add all of our accounts to a mapping with the given index as the value.
            for (int i = 0; i < Accounts.Length; i++)
            {
                // We set a value for each account that is non-zero (zero values aren't stored, the storage entry is deleted).
                await _contract.updateSimpleMapping(Accounts[i], i + 700);
            }

            // Add some other values to a nested mapping (every enum will alternate between SECOND and THIRD)
            for (int i = 1; i <= 10; i++)
            {
                await _contract.updateNestedMapping(i, i * 2, (byte)((i % 2) + 1));
            }

            // Throw an exception in a function call.
            await _contract.throwWithLocals(778899, 100).ExpectRevertTransaction();

            // Obtain an execution trace and parse locals from the last point in it (where the exception occurred).
            var executionTrace = await RpcClient.GetExecutionTrace();

            ExecutionTraceAnalysis traceAnalysis = new ExecutionTraceAnalysis(executionTrace);

            // Obtain our local/state variables.
            var localVariables = traceAnalysis.GetLocalVariables(RpcClient);
            var stateVariables = traceAnalysis.GetStateVariables(RpcClient);

            // TODO: Verify variables.
            Assert.Inconclusive();
        }
示例#2
0
        public async Task TestMappings()
        {
            // Add all of our accounts to a mapping with the given index as the value.
            for (int i = 0; i < Accounts.Length; i++)
            {
                // We set a value for each account that is non-zero (zero values aren't stored, the storage entry is deleted).
                await _contract.updateSimpleMapping(Accounts[i], i + 700);
            }

            // Add some other values to a nested mapping (every enum will alternate between SECOND and THIRD)
            for (int i = 1; i <= 10; i++)
            {
                await _contract.updateNestedMapping(i, i * 2, (byte)((i % 2) + 1));
            }

            // Throw an exception in a function call.
            await _contract.throwWithLocals(778899, 100).ExpectRevertTransaction();

            // TODO: Verify variables.
            Assert.Inconclusive();
        }