<commit_before>require('proof')(6, require('cadence')(prove))

function prove (async, assert) {
    var Coordinator = require('../../reconfigure/coordinator')
    var con = {
        added: false,
        listeners: false,
        initialize: function (callback) {
            callback(null)
        },
        addListener: function (url, callback) {
            if (this.added) {
                callback(null, false)
            } else {
                this.added = true
                callback(null, {
                    node: {
                        value: url
                    }
                })
            }
        },
        removeListener: function (url, callback) {
            callback(null, true)
        },
        listeners: function (callback) {
            callback(null, [['127.0.0.1:8081']])
        },
        list: function (callback) {
            callback(null, { key: 'a val', anotherkey: 'a val' })
        }
    }

    var ua = {
        added: false,
        update: function (url, properties, callback) {
            if (!this.added) {
                callback(null, false)
                this.added = true
            } else { callback(null, true) }
        }
    }

    var coordinator = new Coordinator(con, ua)

    async(function () {
        con.initialize(async())
    }, function () {
        coordinator.listen('127.0.0.1:8081', async())
    }, function (listening) {
        assert(listening, true, 'listen on 8081')
    }, function () {
        coordinator.listen('127.0.0.1:8081', async())
    }, function (extant) {
        assert(extant, true, 'no dupes')
        coordinator.retry(async()) //empty run for coverage
    }, function () {
        coordinator.update(async()) // fail so we can retry
    }, function () {
        assert(coordinator._failed, { '127.0.0.1:8081': true }, 'waiting to retry')
        coordinator.update(async()) // test update
    }, function (updated) {
        assert(updated, true, 'updated')
        coordinator.retry(async()) // test retry
    }, function () {
        assert(coordinator._failed, {}, 'retried')
        coordinator.unlisten('127.0.0.1:8081', async())
    }, function (unlisten) {
        assert(unlisten, true, 'unlisten on 8081')
    })
}
<commit_msg>Test all update/retry branches.<commit_after>require('proof')(6, require('cadence')(prove))

function prove (async, assert) {
    var Coordinator = require('../../reconfigure/coordinator')
    var con = {
        added: false,
        listeners: false,
        initialize: function (callback) {
            callback(null)
        },
        addListener: function (url, callback) {
            if (this.added) {
                callback(null, false)
            } else {
                this.added = true
                callback(null, {
                    node: {
                        value: url
                    }
                })
            }
        },
        removeListener: function (url, callback) {
            callback(null, true)
        },
        listeners: function (callback) {
            callback(null, [['127.0.0.1:8081']])
        },
        list: function (callback) {
            callback(null, { key: 'a val', anotherkey: 'a val' })
        }
    }

    var ua = {
        added: false,
        update: function (url, properties, callback) {
            if (!this.added) {
                callback(null, false)
                this.added = true
            } else { callback(null, true) }
        }
    }

    var coordinator = new Coordinator(con, ua)

    async(function () {
        con.initialize(async())
    }, function () {
        coordinator.listen('127.0.0.1:8081', async())
    }, function (listening) {
        assert(listening, true, 'listen on 8081')
    }, function () {
        coordinator.listen('127.0.0.1:8081', async())
    }, function (extant) {
        assert(extant, true, 'no dupes')
        coordinator.retry(async()) //empty run for coverage
    }, function () {
        coordinator.update(async()) // fail so we can retry
    }, function () {
        assert(coordinator._failed, { '127.0.0.1:8081': true }, 'waiting to retry')
        coordinator.update(async()) // test update
    }, function (updated) {
        assert(updated, true, 'updated')
        coordinator.retry(async()) // test retry
    }, function () {
        assert(coordinator._failed, {}, 'retried')
        ua.added = false
        coordinator._failed['127.0.0.1:8081'] = true // screw up the state and
                                                     // retry, should be ok
        coordinator.retry(async()) // test retry
    }, function () {
        coordinator.unlisten('127.0.0.1:8081', async())
    }, function (unlisten) {
        assert(unlisten, true, 'unlisten on 8081')
    })
}

{'fraction_non_alphanumeric': 0.14180980310012567, 'fraction_numerical': 0.026811897779639715, 'mean_word_length': 1.685601799775028, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 11, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3197861', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1327, 'n_words': 302}