コード例 #1
0
        public async Task TooManyInputsAsync()
        {
            MockArena      arena = new();
            WabiSabiConfig cfg   = new() { MaxInputCountByAlice = 3 };
            var            round = WabiSabiFactory.CreateRound(cfg);

            arena.OnTryGetRound = _ => round;

            await using PostRequestHandler handler = new(cfg, new Prison(), arena, new MockRpcClient());
            var req = WabiSabiFactory.CreateInputsRegistrationRequest(WabiSabiFactory.CreateInputRoundSignaturePairs(4), round);
            var ex  = await Assert.ThrowsAsync <WabiSabiProtocolException>(async() => await handler.RegisterInputAsync(req));

            Assert.Equal(WabiSabiProtocolErrorCode.TooManyInputs, ex.ErrorCode);
        }
コード例 #2
0
        public async Task TooManyInputsAsync()
        {
            WabiSabiConfig cfg   = new() { MaxInputCountByAlice = 3 };
            var            round = WabiSabiFactory.CreateRound(cfg);

            using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);

            using Key key = new();

            await using ArenaRequestHandler handler = new(cfg, new(), arena, WabiSabiFactory.CreateMockRpc(key));
            var req = WabiSabiFactory.CreateInputsRegistrationRequest(WabiSabiFactory.CreateInputRoundSignaturePairs(4), round);
            var ex  = await Assert.ThrowsAsync <WabiSabiProtocolException>(async() => await handler.RegisterInputAsync(req));

            Assert.Equal(WabiSabiProtocolErrorCode.TooManyInputs, ex.ErrorCode);

            await arena.StopAsync(CancellationToken.None);
        }
コード例 #3
0
        public async Task RoundFullAliceMultiInputAsync()
        {
            WabiSabiConfig cfg   = new() { MaxInputCountByRound = 3 };
            var            round = WabiSabiFactory.CreateRound(cfg);

            using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);

            round.Alices.Add(WabiSabiFactory.CreateAlice(WabiSabiFactory.CreateInputRoundSignaturePairs(2)));
            await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));

            Assert.Equal(Phase.InputRegistration, round.Phase);

            round.Alices.Add(WabiSabiFactory.CreateAlice());
            await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));

            Assert.Equal(Phase.ConnectionConfirmation, round.Phase);

            await arena.StopAsync(CancellationToken.None);
        }
コード例 #4
0
        public async Task InputRegistrationFullAsync()
        {
            WabiSabiConfig cfg   = new() { MaxInputCountByRound = 3 };
            var            round = WabiSabiFactory.CreateRound(cfg);

            using Arena arena = await WabiSabiFactory.CreateAndStartArenaAsync(cfg, round);

            using Key key = new();

            var req = WabiSabiFactory.CreateInputsRegistrationRequest(key, round);

            await using ArenaRequestHandler handler = new(cfg, new(), arena, WabiSabiFactory.CreateMockRpc(key));

            await arena.TriggerAndWaitRoundAsync(TimeSpan.FromSeconds(21));

            round.Alices.Add(WabiSabiFactory.CreateAlice());
            round.Alices.Add(WabiSabiFactory.CreateAlice(WabiSabiFactory.CreateInputRoundSignaturePairs(2)));
            await RegisterAndAssertWrongPhaseAsync(req, handler);

            Assert.Equal(Phase.InputRegistration, round.Phase);

            await arena.StopAsync(CancellationToken.None);
        }