예제 #1
0
def testStewardCannotAddNodeWithInvalidHa(looper, tdir, txnPoolNodeSet,
                                          newAdHocSteward):
    """
    The case:
        Steward accidentally sends the NODE txn with an invalid HA.
    The expected result:
        Steward gets NAck response from the pool.
    """
    newNodeName = "Epsilon"

    newSteward, newStewardWallet = newAdHocSteward

    # a sequence of the test cases for each field
    tests = itertools.chain(
        itertools.product((NODE_IP, CLIENT_IP),
                          ('127.0.0.1 ', '256.0.0.1', '0.0.0.0')),
        itertools.product((NODE_PORT, CLIENT_PORT),
                          ('foo', '9700', 0, 65535 + 1, 4351683546843518184)),
    )

    for field, value in tests:
        # create a transform function for each test
        def _tnf(op):
            op[DATA].update({field: value})

        sendAddNewNode(newNodeName,
                       newSteward,
                       newStewardWallet,
                       transformOpFunc=_tnf)
        # wait NAcks with exact message. it does not works for just 'is invalid'
        # because the 'is invalid' will check only first few cases
        waitReqNackFromPoolWithReason(looper, txnPoolNodeSet, newSteward,
                                      "invalid network ip address")
예제 #2
0
def testStewardCannotAddNodeWithOutFullFieldsSet(looper, tdir,
                                                 txnPoolNodeSet,
                                                 newAdHocSteward):
    """
    The case:
        Steward accidentally sends the NODE txn without full fields set.
    The expected result:
        Steward gets NAck response from the pool.
    """
    newNodeName = "Epsilon"

    newSteward, newStewardWallet = newAdHocSteward

    # case from the ticket
    def _renameNodePortField(op):
        op[DATA].update({NODE_PORT + ' ': op[DATA][NODE_PORT]})
        del op[DATA][NODE_PORT]

    sendAddNewNode(tdir, newNodeName, newSteward, newStewardWallet,
                   transformOpFunc=_renameNodePortField)
    waitReqNackFromPoolWithReason(looper, txnPoolNodeSet, newSteward,
                                  "unknown field")

    for fn in (NODE_IP, CLIENT_IP, NODE_PORT, CLIENT_PORT):
        def _tnf(op): del op[DATA][fn]

        sendAddNewNode(tdir, newNodeName, newSteward, newStewardWallet,
                       transformOpFunc=_tnf)
        # wait NAcks with exact message. it does not works for just 'is missed'
        # because the 'is missed' will check only first few cases
        waitReqNackFromPoolWithReason(looper, txnPoolNodeSet, newSteward,
                                      "unknown field")
예제 #3
0
def testStewardCannotAddNodeWithNonBase58VerKey(looper, tdir, txnPoolNodeSet,
                                                newAdHocSteward):
    """
    The Case:
        Steward accidentally sends the NODE txn with a non base58 verkey.
    The expected result:
        Steward gets NAck response from the pool.
    """
    # create a new steward
    newSteward, newStewardWallet = newAdHocSteward

    newNodeName = "Epsilon"

    # get hex VerKey
    sigseed = randomString(32).encode()
    nodeSigner = SimpleSigner(seed=sigseed)
    b = base58.b58decode(nodeSigner.identifier)
    hexVerKey = bytearray(b).hex()

    def _setHexVerkey(op):
        op[TARGET_NYM] = hexVerKey
        return op

    sendAddNewNode(newNodeName,
                   newSteward,
                   newStewardWallet,
                   transformOpFunc=_setHexVerkey)
    waitReqNackFromPoolWithReason(looper, txnPoolNodeSet, newSteward,
                                  'should not contain the following chars')
def test_plugin_static_validation(nodeSet, looper, stewardWallet,
                                  steward1, client1Connected,
                                  sdk_wallet_steward, sdk_pool_handle):
    """
    Check plugin static validation fails and passes
    """
    op = {
        TXN_TYPE: AUCTION_START
    }
    send_signed_requests(steward1, sign_requests(stewardWallet, [op, ]))
    waitReqNackFromPoolWithReason(looper, nodeSet, steward1,
                                  'attribute is missing or not in proper format')

    op = {
        TXN_TYPE: AUCTION_START,
        DATA: 'should be a dict but giving a string'
    }
    send_signed_requests(steward1, sign_requests(stewardWallet, [op, ]))
    waitReqNackFromPoolWithReason(looper, nodeSet, steward1,
                                  'attribute is missing or not in proper format')

    op = {
        TXN_TYPE: AUCTION_START,
        DATA: {'id': 'abc'}
    }

    successful_op(looper, op, sdk_wallet_steward, sdk_pool_handle)

    op = {
        TXN_TYPE: PLACE_BID,
        DATA: {'id': 'abc', AMOUNT: -3}
    }
    send_signed_requests(steward1, sign_requests(stewardWallet, [op, ]))
    waitReqNackFromPoolWithReason(looper, nodeSet, steward1,
                                  'must be present and should be a number')

    op = {
        TXN_TYPE: PLACE_BID,
        DATA: {'id': 'abc', AMOUNT: 20}
    }
    successful_op(looper, op, sdk_wallet_steward, sdk_pool_handle)