def test_fire_wrong_turn(self):
        layout = BoardLayout(10)
        layout.append(
            ShipPosition(text='AA', row=0, column=0, orientation='horizontal'))
        nonces = create_nonces(10)

        # Send join payload to tp
        fire_req = create_fire_payload('invalid_row', '1', 'Z')

        self.validator.send(
            self.player_1.create_tp_process_request(fire_req)
        )

        # give state back to tp

        self.send_state_to_tp('invalid_row', {
            'Ships': ['AA'],
            'TargetBoard1': [['?'] * 10 for _ in range(10)],
            'TargetBoard2': [['?'] * 10 for _ in range(10)],
            'Player1': self.public_key_1,
            'Player2': self.public_key_2,
            'HashedBoard1': layout.render_hashed(nonces),
            'HashedBoard2': layout.render_hashed(nonces),
            'State': 'P2-NEXT'
        })

        self.expect_invalid()
    def test_fire_game_won(self):
        # Create test board
        layout = BoardLayout(10)
        layout.append(
            ShipPosition(text='AA', row=0, column=0, orientation='horizontal'))
        nonces = create_nonces(10)

        # Player 2 fires
        fire_req = \
            create_fire_payload('fire_game', '1', 'B', 'A', nonces[0][1])

        self.validator.send(
            self.player_2.create_tp_process_request(fire_req))

        target_board1 = [['?'] * 10 for _ in range(10)]
        target_board1[0][0] = 'H'

        self.send_state_to_tp('fire_game', {
            'Ships': ['AA'],
            'TargetBoard1': target_board1,
            'TargetBoard2': [['?'] * 10 for _ in range(10)],
            'Player1': self.public_key_1,
            'Player2': self.public_key_2,
            'HashedBoard1': layout.render_hashed(nonces),
            'HashedBoard2': layout.render_hashed(nonces),
            'State': 'P2-NEXT',
            'LastFireRow': '1',
            'LastFireColumn': 'B'
        }, self.player_2)

        target_board1[0][1] = 'H'

        self.update_state('fire_game', {
            'Ships': ['AA'],
            'TargetBoard1': target_board1,
            'TargetBoard2': [['?'] * 10 for _ in range(10)],
            'Player1': self.public_key_1,
            'Player2': self.public_key_2,
            'HashedBoard1': layout.render_hashed(nonces),
            'HashedBoard2': layout.render_hashed(nonces),
            'LastFireRow': '1',
            'LastFireColumn': 'B',
            'State': 'P1-WIN'
        }, self.player_2)

        self.expect_ok()